diff --git a/packages/backend/src/apps/firebase/assets/favicon.svg b/packages/backend/src/apps/firebase/assets/favicon.svg deleted file mode 100644 index bd2ee11b..00000000 --- a/packages/backend/src/apps/firebase/assets/favicon.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/backend/src/apps/firebase/authentication.ts b/packages/backend/src/apps/firebase/authentication.ts deleted file mode 100644 index 921598ac..00000000 --- a/packages/backend/src/apps/firebase/authentication.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type { - IAuthentication, - IApp, - IField, - IJSONObject, -} from '@automatisch/types'; -import { google as GoogleApi } from 'googleapis'; -import { OAuth2Client } from 'google-auth-library'; - -export default class Authentication implements IAuthentication { - appData: IApp; - connectionData: IJSONObject; - client: OAuth2Client; - - scopes: string[] = [ - 'https://www.googleapis.com/auth/datastore', - 'https://www.googleapis.com/auth/firebase', - 'https://www.googleapis.com/auth/user.emails.read', - 'profile', - ]; - - constructor(appData: IApp, connectionData: IJSONObject) { - this.appData = appData; - this.connectionData = connectionData; - - this.client = new GoogleApi.auth.OAuth2( - connectionData.consumerKey as string, - connectionData.consumerSecret as string, - this.oauthRedirectUrl - ); - - GoogleApi.options({ auth: this.client }); - } - - get oauthRedirectUrl() { - return this.appData.fields.find( - (field: IField) => field.key == 'oAuthRedirectUrl' - ).value; - } - - async createAuthData() { - const url = this.client.generateAuthUrl({ - access_type: 'offline', - scope: this.scopes, - }); - - return { url }; - } - - async verifyCredentials() { - const { tokens } = await this.client.getToken( - this.connectionData.oauthVerifier as string - ); - this.client.setCredentials(tokens); - - const people = GoogleApi.people('v1'); - - const { data } = await people.people.get({ - resourceName: 'people/me', - personFields: 'emailAddresses', - }); - - const { emailAddresses, resourceName: userId } = data; - const primaryEmailAddress = emailAddresses.find( - (emailAddress) => emailAddress.metadata.primary - ); - - return { - consumerKey: this.connectionData.consumerKey, - consumerSecret: this.connectionData.consumerSecret, - accessToken: tokens.access_token, - refreshToken: tokens.refresh_token, - tokenType: tokens.token_type, - expiryDate: tokens.expiry_date, - scope: tokens.scope, - screenName: primaryEmailAddress.value, - userId, - }; - } - - async isStillVerified() { - try { - await this.client.getTokenInfo(this.connectionData.accessToken as string); - return true; - } catch { - return false; - } - } -} diff --git a/packages/backend/src/apps/firebase/index.d.ts b/packages/backend/src/apps/firebase/index.d.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/backend/src/apps/firebase/index.ts b/packages/backend/src/apps/firebase/index.ts deleted file mode 100644 index db7a01e4..00000000 --- a/packages/backend/src/apps/firebase/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import Authentication from './authentication'; -import { - IService, - IAuthentication, - IApp, - IJSONObject, -} from '@automatisch/types'; - -export default class Firebase implements IService { - authenticationClient: IAuthentication; - - constructor(appData: IApp, connectionData: IJSONObject) { - this.authenticationClient = new Authentication(appData, connectionData); - } -} diff --git a/packages/backend/src/apps/firebase/info.json b/packages/backend/src/apps/firebase/info.json deleted file mode 100644 index c3b8104c..00000000 --- a/packages/backend/src/apps/firebase/info.json +++ /dev/null @@ -1,219 +0,0 @@ -{ - "name": "Firebase", - "key": "firebase", - "iconUrl": "{BASE_URL}/apps/firebase/assets/favicon.svg", - "docUrl": "https://automatisch.io/docs/firebase", - "primaryColor": "ffca28", - "supportsConnections": true, - "fields": [ - { - "key": "oAuthRedirectUrl", - "label": "OAuth Redirect URL", - "type": "string", - "required": true, - "readOnly": true, - "value": "{WEB_APP_URL}/app/firebase/connections/add", - "placeholder": null, - "description": "When asked to input an OAuth callback or redirect URL in Firebase OAuth, enter the URL above.", - "docUrl": "https://automatisch.io/docs/firebase#oauth-redirect-url", - "clickToCopy": true - }, - { - "key": "consumerKey", - "label": "Consumer Key", - "type": "string", - "required": true, - "readOnly": false, - "value": null, - "placeholder": null, - "description": null, - "docUrl": "https://automatisch.io/docs/firebase#consumer-key", - "clickToCopy": false - }, - { - "key": "consumerSecret", - "label": "Consumer Secret", - "type": "string", - "required": true, - "readOnly": false, - "value": null, - "placeholder": null, - "description": null, - "docUrl": "https://automatisch.io/docs/firebase#consumer-secret", - "clickToCopy": false - } - ], - "authenticationSteps": [ - { - "step": 1, - "type": "mutation", - "name": "createConnection", - "arguments": [ - { - "name": "key", - "value": "{key}" - }, - { - "name": "formattedData", - "value": null, - "properties": [ - { - "name": "consumerKey", - "value": "{fields.consumerKey}" - }, - { - "name": "consumerSecret", - "value": "{fields.consumerSecret}" - } - ] - } - ] - }, - { - "step": 2, - "type": "mutation", - "name": "createAuthData", - "arguments": [ - { - "name": "id", - "value": "{createConnection.id}" - } - ] - }, - { - "step": 3, - "type": "openWithPopup", - "name": "openAuthPopup", - "arguments": [ - { - "name": "url", - "value": "{createAuthData.url}" - } - ] - }, - { - "step": 4, - "type": "mutation", - "name": "updateConnection", - "arguments": [ - { - "name": "id", - "value": "{createConnection.id}" - }, - { - "name": "formattedData", - "value": null, - "properties": [ - { - "name": "oauthVerifier", - "value": "{openAuthPopup.code}" - } - ] - } - ] - }, - { - "step": 5, - "type": "mutation", - "name": "verifyConnection", - "arguments": [ - { - "name": "id", - "value": "{createConnection.id}" - } - ] - } - ], - "reconnectionSteps": [ - { - "step": 1, - "type": "mutation", - "name": "resetConnection", - "arguments": [ - { - "name": "id", - "value": "{connection.id}" - } - ] - }, - { - "step": 2, - "type": "mutation", - "name": "updateConnection", - "arguments": [ - { - "name": "id", - "value": "{connection.id}" - }, - { - "name": "formattedData", - "value": null, - "properties": [ - { - "name": "consumerKey", - "value": "{fields.consumerKey}" - }, - { - "name": "consumerSecret", - "value": "{fields.consumerSecret}" - } - ] - } - ] - }, - { - "step": 3, - "type": "mutation", - "name": "createAuthData", - "arguments": [ - { - "name": "id", - "value": "{connection.id}" - } - ] - }, - { - "step": 4, - "type": "openWithPopup", - "name": "openAuthPopup", - "arguments": [ - { - "name": "url", - "value": "{createAuthData.url}" - } - ] - }, - { - "step": 5, - "type": "mutation", - "name": "updateConnection", - "arguments": [ - { - "name": "id", - "value": "{connection.id}" - }, - { - "name": "formattedData", - "value": null, - "properties": [ - { - "name": "oauthVerifier", - "value": "{openAuthPopup.code}" - } - ] - } - ] - }, - { - "step": 6, - "type": "mutation", - "name": "verifyConnection", - "arguments": [ - { - "name": "id", - "value": "{connection.id}" - } - ] - } - ] -}