diff --git a/index.js b/index.js new file mode 100644 index 0000000..a02e4f6 --- /dev/null +++ b/index.js @@ -0,0 +1,87 @@ +const Express = require('express') +const app = Express() +const port = (process.env.PORT || 3030) + +const axios = require('axios') +require('dotenv').config() + +const favicon = require('serve-favicon'); +app.use(favicon(__dirname + '/public/favicon.ico')); + +const hbs = require('hbs') + +hbs.registerPartials(__dirname + '/views/partials') +app.set('view engine', 'hbs') + +app.use(Express.static('public')); + +app.get('/', (req, res) => { + res.render('index') +}) + +app.get('/auth', async (req, res) => { + + async function requestAccessToken() { + try { + const reqData = { + code: req.query.code, + grant_type: "authorization_code", + redirect_uri: "https://telegram-to-notion.herokuapp.com/auth" + } + + const auth = { + Authorization: "Basic " + Buffer.from(`${process.env.NOTION_INTEGRATION_ID}:${process.env.NOTION_INTEGRATION_SECRET}`).toString('base64') + } + + console.log(auth) + + const response = await axios({ + method: "POST", + url: "https://api.notion.com/v1/oauth/token", + data: reqData, + auth: { + username: Buffer.from(process.env.NOTION_INTEGRATION_ID.toString('base64')), + password: Buffer.from(process.env.NOTION_INTEGRATION_SECRET.toString('base64')) + } //THANK YOU https://stackoverflow.com/questions/67534080/notion-api-invalid-client-oauth-integration/68699544#68699544?newreg=949504cf865c4a52b2c0ce7afe936c9b + }) + + console.log(response.status) //400 in positive case + console.log(response.data) + + /** + * access_token: string, + * token_type: string, + * bot_id: string, + * workspace_name: string, + * workspace_icon: string, + * workspace_id: string + */ + + return response + } + catch (error) { + console.log("error") + console.log(error) + + return {status: 400} + } + } + + const response = await requestAccessToken() + + res.render('auth', { + name: "fran", + success: response.status === 200 ? true : false, + data: response.data + }) +}) + +app.get('/privacy-policy', (req, res) => { + res.render('privacy-policy') +}) + +app.get('/terms-of-use', (req, res) => { + res.render('terms-of-use') +}) + +app.listen(port, () => console.log('port', port)) \ No newline at end of file diff --git a/public/css/auth.css b/public/css/auth.css new file mode 100644 index 0000000..f5a785c --- /dev/null +++ b/public/css/auth.css @@ -0,0 +1,29 @@ +.request-success { + + display: flex; + align-items: center; + + background-color: #ffebcd; + + padding: 3vh 0px 3vh 2vw; + + user-select: all; + -webkit-user-select: all; +} + +.request-success code { + overflow-wrap: anywhere; +} + +.request-success img { + + width: 50px; + + margin-right: 3vw; + + user-select: none; +} + +.request-error { + color: rgb(143, 0, 0) +} \ No newline at end of file diff --git a/public/css/global.css b/public/css/global.css new file mode 100644 index 0000000..c20e0a9 --- /dev/null +++ b/public/css/global.css @@ -0,0 +1,21 @@ +html, body { + margin: 0; + padding: 0; +} + +body { + margin: 0vh 3vw; + font-family: 'Be Vietnam Pro', sans-serif; +} + +#beta-banner { + background-color: #F38181; + color: #393E46; + + padding: 2vh 0.5vw; + margin: 0px -3vw; +} + +#beta-banner p { + margin: 0; +} \ No newline at end of file diff --git a/public/css/index.css b/public/css/index.css new file mode 100644 index 0000000..2a346e1 --- /dev/null +++ b/public/css/index.css @@ -0,0 +1,26 @@ +.main { + display: flex; + flex-direction: column; +} + +.button { + width: fit-content; + + background-color: #4797ff; + color: #fff; + + padding: 2vh 5vw; + + border-radius: 5px; + + text-decoration: none; + font-weight: bold; +} + +ul { + margin-top: 5vh; +} +ul li{ + font-size: 20pt; + font-weight: bold; +} \ No newline at end of file diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000..e4e0bf7 Binary files /dev/null and b/public/favicon.png differ diff --git a/public/img/auth_copy.svg b/public/img/auth_copy.svg new file mode 100644 index 0000000..2eb127c --- /dev/null +++ b/public/img/auth_copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/README.md b/readme.MD similarity index 100% rename from README.md rename to readme.MD diff --git a/src/Pages/Auth.jsx b/src/Pages/Auth.jsx new file mode 100644 index 0000000..f2a71a1 --- /dev/null +++ b/src/Pages/Auth.jsx @@ -0,0 +1,79 @@ +import React, {useState} from "react" +import axios from 'axios' + +function Auth() { + + const [loading, setLoading] = useState(true) + const [permanentCode, setPermanentCode] = useState(false) + + const getPermanentCode = () => { + + const temporalCode = new URLSearchParams(window.location.search).get("code") + console.log(temporalCode); + + if (!temporalCode) { + console.log("No temporal code") + return + } + + let requestUrl + + if (process.env.REACT_APP_ENV_MODE === "production") { + requestUrl = "https://telegram-to-notion-backend.herokuapp.com/api/v1/auth" + } else { + requestUrl = "http://localhost:5050/api/v1/auth" + } + + axios({ + method: "POST", + url: requestUrl, + headers: {'Content-Type': 'application/json'}, + data: {code: temporalCode} + }) + .then(res => { + console.log(res) + setPermanentCode(res ? res.data : null) + }) + .catch(err => { + console.log(err.response) + setPermanentCode(false) + }) + .finally(() => { + setLoading(false) + }) + } + React.useEffect(() => { + getPermanentCode() + }, []) + + + return ( +
+ { + // loading ? + // // + //

Loading

+ // : + // <> + // { + // permanentCode ? + // <> + //

Copy the following code on the Telegram chat

+ //
+ // + // {permanentCode} + // + //
+ // + // : + //
+ //

There has been an error getting the code. Please try again later.

+ //
+ // } + // + } +
+ ) +} + +export default Auth \ No newline at end of file diff --git a/src/Pages/Index.jsx b/src/Pages/Index.jsx new file mode 100644 index 0000000..53702ed --- /dev/null +++ b/src/Pages/Index.jsx @@ -0,0 +1,59 @@ +import styled from "styled-components" + +function Index() { + + const Div = styled.div` + + .title-list { + + color: #000; + + li { + + a { + width: fit-content; + color: #000; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + + h2 { + display: inline-block; + margin: 0; + } + + span { + display: inline-block; + margin-left: 1vw; + } + } + } + ` + + const listData = [ + {text: "Free"}, + {text: "Open Source", link: "https://github.com/FranP-code/Telegram-to-Notion-Bot"}, + {text: "Unlimited"}, + {text: "Forever", secondaryText: "(while I can afford it)"} + ] + + return ( +
+ +
+ ) +} + +export default Index \ No newline at end of file diff --git a/src/components/Header.jsx b/src/components/Header.jsx new file mode 100644 index 0000000..22db147 --- /dev/null +++ b/src/components/Header.jsx @@ -0,0 +1,9 @@ +function Header() { + return ( +
+

Telegram to Notion

+
+ ) +} + +export default Header \ No newline at end of file diff --git a/views/auth.hbs b/views/auth.hbs new file mode 100644 index 0000000..bcc32c1 --- /dev/null +++ b/views/auth.hbs @@ -0,0 +1,19 @@ +{{> global cssFile="auth"}} + + + {{> betaBanner }} +
+ {{#if success}} +

Copy the following code on the Telegram chat

+
+ copy + {{data.access_token}} +
+ {{else}} +
+

There has been an error authorizing the app, please try again

+
+ {{/if}} +
+ + \ No newline at end of file diff --git a/views/index.hbs b/views/index.hbs new file mode 100644 index 0000000..398aa23 --- /dev/null +++ b/views/index.hbs @@ -0,0 +1,14 @@ +{{> global cssFile="index"}} + + + {{> betaBanner }} +
+

Telegram to Notion Bot's website

+
Here you can visit it! + +
+ \ No newline at end of file diff --git a/views/partials/betaBanner.hbs b/views/partials/betaBanner.hbs new file mode 100644 index 0000000..54c4b75 --- /dev/null +++ b/views/partials/betaBanner.hbs @@ -0,0 +1,3 @@ +
+

This website is on beta version. Futures updates will be to make more aesthetic the website for all users. Thanks for the compression

+
\ No newline at end of file diff --git a/views/partials/global.hbs b/views/partials/global.hbs new file mode 100644 index 0000000..07af0e2 --- /dev/null +++ b/views/partials/global.hbs @@ -0,0 +1,13 @@ + + + + + + + + + + Telegram to Notion Bot + + + \ No newline at end of file diff --git a/views/privacy-policy.hbs b/views/privacy-policy.hbs new file mode 100644 index 0000000..d6e50a2 --- /dev/null +++ b/views/privacy-policy.hbs @@ -0,0 +1,138 @@ +{{> global }} + + + {{> betaBanner }} +
+

Privacy Policy

+

Last updated: April 11, 2022

+

This Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your information when You use the Service and tells You about Your privacy rights and how the law protects You.

+

We use Your Personal data to provide and improve the Service. By using the Service, You agree to the collection and use of information in accordance with this Privacy Policy. This Privacy Policy has been created with the help of the Privacy Policy Template.

+

Interpretation and Definitions

+

Interpretation

+

The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural.

+

Definitions

+

For the purposes of this Privacy Policy:

+ +

Collecting and Using Your Personal Data

+

Types of Data Collected

+

Personal Data

+

While using Our Service, We may ask You to provide Us with certain personally identifiable information that can be used to contact or identify You. Personally identifiable information may include, but is not limited to:

+ +

Usage Data

+

Usage Data is collected automatically when using the Service.

+

Usage Data may include information such as Your Device's Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our Service that You visit, the time and date of Your visit, the time spent on those pages, unique device identifiers and other diagnostic data.

+

When You access the Service by or through a mobile device, We may collect certain information automatically, including, but not limited to, the type of mobile device You use, Your mobile device unique ID, the IP address of Your mobile device, Your mobile operating system, the type of mobile Internet browser You use, unique device identifiers and other diagnostic data.

+

We may also collect information that Your browser sends whenever You visit our Service or when You access the Service by or through a mobile device.

+

Use of Your Personal Data

+

The Company may use Personal Data for the following purposes:

+ +

We may share Your personal information in the following situations:

+ +

Retention of Your Personal Data

+

The Company will retain Your Personal Data only for as long as is necessary for the purposes set out in this Privacy Policy. We will retain and use Your Personal Data to the extent necessary to comply with our legal obligations (for example, if we are required to retain your data to comply with applicable laws), resolve disputes, and enforce our legal agreements and policies.

+

The Company will also retain Usage Data for internal analysis purposes. Usage Data is generally retained for a shorter period of time, except when this data is used to strengthen the security or to improve the functionality of Our Service, or We are legally obligated to retain this data for longer time periods.

+

Transfer of Your Personal Data

+

Your information, including Personal Data, is processed at the Company's operating offices and in any other places where the parties involved in the processing are located. It means that this information may be transferred to — and maintained on — computers located outside of Your state, province, country or other governmental jurisdiction where the data protection laws may differ than those from Your jurisdiction.

+

Your consent to this Privacy Policy followed by Your submission of such information represents Your agreement to that transfer.

+

The Company will take all steps reasonably necessary to ensure that Your data is treated securely and in accordance with this Privacy Policy and no transfer of Your Personal Data will take place to an organization or a country unless there are adequate controls in place including the security of Your data and other personal information.

+

Disclosure of Your Personal Data

+

Business Transactions

+

If the Company is involved in a merger, acquisition or asset sale, Your Personal Data may be transferred. We will provide notice before Your Personal Data is transferred and becomes subject to a different Privacy Policy.

+

Law enforcement

+

Under certain circumstances, the Company may be required to disclose Your Personal Data if required to do so by law or in response to valid requests by public authorities (e.g. a court or a government agency).

+

Other legal requirements

+

The Company may disclose Your Personal Data in the good faith belief that such action is necessary to:

+ +

Security of Your Personal Data

+

The security of Your Personal Data is important to Us, but remember that no method of transmission over the Internet, or method of electronic storage is 100% secure. While We strive to use commercially acceptable means to protect Your Personal Data, We cannot guarantee its absolute security.

+

Children's Privacy

+

Our Service does not address anyone under the age of 13. We do not knowingly collect personally identifiable information from anyone under the age of 13. If You are a parent or guardian and You are aware that Your child has provided Us with Personal Data, please contact Us. If We become aware that We have collected Personal Data from anyone under the age of 13 without verification of parental consent, We take steps to remove that information from Our servers.

+

If We need to rely on consent as a legal basis for processing Your information and Your country requires consent from a parent, We may require Your parent's consent before We collect and use that information.

+

Links to Other Websites

+

Our Service may contain links to other websites that are not operated by Us. If You click on a third party link, You will be directed to that third party's site. We strongly advise You to review the Privacy Policy of every site You visit.

+

We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.

+

Changes to this Privacy Policy

+

We may update Our Privacy Policy from time to time. We will notify You of any changes by posting the new Privacy Policy on this page.

+

We will let You know via email and/or a prominent notice on Our Service, prior to the change becoming effective and update the "Last updated" date at the top of this Privacy Policy.

+

You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.

+

Contact Us

+

If you have any questions about this Privacy Policy, You can contact us:

+ +
+ \ No newline at end of file diff --git a/views/terms-of-use.hbs b/views/terms-of-use.hbs new file mode 100644 index 0000000..72c20d8 --- /dev/null +++ b/views/terms-of-use.hbs @@ -0,0 +1,24 @@ +{{> global cssFile="index"}} + + {{> betaBanner }} +
+

Terms and conditions

+

These terms and conditions (“Agreement”) set forth the general terms and conditions of your use of the “Telegram to Notion Bot” mobile application (“Mobile Application” or “Service”) and any of its related products and services (collectively, “Services”). This Agreement is legally binding between you (“User”, “you” or “your”) and this Mobile Application developer (“Operator”, “we”, “us” or “our”). If you are entering into this agreement on behalf of a business or other legal entity, you represent that you have the authority to bind such entity to this agreement, in which case the terms “User”, “you” or “your” shall refer to such entity. If you do not have such authority, or if you do not agree with the terms of this agreement, you must not accept this agreement and may not access and use the Mobile Application and Services. By accessing and using the Mobile Application and Services, you acknowledge that you have read, understood, and agree to be bound by the terms of this Agreement. You acknowledge that this Agreement is a contract between you and the Operator, even though it is electronic and is not physically signed by you, and it governs your use of the Mobile Application and Services. This terms and conditions policy was created with the help of the terms and conditions generator.

+

Accounts and membership

+

You must be at least 16 years of age to use the Mobile Application and Services. By using the Mobile Application and Services and by agreeing to this Agreement you warrant and represent that you are at least 16 years of age.

+

If you create an account in the Mobile Application, you are responsible for maintaining the security of your account and you are fully responsible for all activities that occur under the account and any other actions taken in connection with it. We may, but have no obligation to, monitor and review new accounts before you may sign in and start using the Services. Providing false contact information of any kind may result in the termination of your account. You must immediately notify us of any unauthorized uses of your account or any other breaches of security. We will not be liable for any acts or omissions by you, including any damages of any kind incurred as a result of such acts or omissions. We may suspend, disable, or delete your account (or any part thereof) if we determine that you have violated any provision of this Agreement or that your conduct or content would tend to damage our reputation and goodwill. If we delete your account for the foregoing reasons, you may not re-register for our Services. We may block your email address and Internet protocol address to prevent further registration.

+

Links to other resources

+

Although the Mobile Application and Services may link to other resources (such as websites, mobile applications, etc.), we are not, directly or indirectly, implying any approval, association, sponsorship, endorsement, or affiliation with any linked resource, unless specifically stated herein. We are not responsible for examining or evaluating, and we do not warrant the offerings of, any businesses or individuals or the content of their resources. We do not assume any responsibility or liability for the actions, products, services, and content of any other third parties. You should carefully review the legal statements and other conditions of use of any resource which you access through a link in the Mobile Application. Your linking to any other off-site resources is at your own risk.

+

Dispute resolution

+

The formation, interpretation, and performance of this Agreement and any disputes arising out of it shall be governed by the substantive and procedural laws of Argentina without regard to its rules on conflicts or choice of law and, to the extent applicable, the laws of Argentina. The exclusive jurisdiction and venue for actions related to the subject matter hereof shall be the courts located in Argentina, and you hereby submit to the personal jurisdiction of such courts. You hereby waive any right to a jury trial in any proceeding arising out of or related to this Agreement. The United Nations Convention on Contracts for the International Sale of Goods does not apply to this Agreement.

+

Changes and amendments

+

We reserve the right to modify this Agreement or its terms related to the Mobile Application and Services at any time at our discretion. When we do, we will revise the updated date at the bottom of this page. We may also provide notice to you in other ways at our discretion, such as through the contact information you have provided.

+

An updated version of this Agreement will be effective immediately upon the posting of the revised Agreement unless otherwise specified. Your continued use of the Mobile Application and Services after the effective date of the revised Agreement (or such other act specified at that time) will constitute your consent to those changes.

+

Acceptance of these terms

+

You acknowledge that you have read this Agreement and agree to all its terms and conditions. By accessing and using the Mobile Application and Services you agree to be bound by this Agreement. If you do not agree to abide by the terms of this Agreement, you are not authorized to access or use the Mobile Application and Services.

+

Contacting us

+

If you have any questions, concerns, or complaints regarding this Agreement, we encourage you to contact us using the details below:

+

franpessano1@gmail.com

+

This document was last updated on April 11, 2022

+
+ \ No newline at end of file