chore: remove unused typeform app
This commit is contained in:
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 6.5 KiB |
@@ -1,100 +0,0 @@
|
|||||||
import type {
|
|
||||||
IAuthentication,
|
|
||||||
IApp,
|
|
||||||
IField,
|
|
||||||
IJSONObject,
|
|
||||||
} from '@automatisch/types';
|
|
||||||
import { URLSearchParams } from 'url';
|
|
||||||
import createHttpClient, { IHttpClient } from '../../helpers/http-client';
|
|
||||||
|
|
||||||
export default class Authentication implements IAuthentication {
|
|
||||||
appData: IApp;
|
|
||||||
connectionData: IJSONObject;
|
|
||||||
client: IHttpClient;
|
|
||||||
|
|
||||||
scope: string[] = [
|
|
||||||
'forms:read',
|
|
||||||
'forms:write',
|
|
||||||
'webhooks:read',
|
|
||||||
'webhooks:write',
|
|
||||||
'responses:read',
|
|
||||||
'accounts:read',
|
|
||||||
'workspaces:read',
|
|
||||||
];
|
|
||||||
|
|
||||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
|
||||||
this.connectionData = connectionData;
|
|
||||||
this.appData = appData;
|
|
||||||
this.client = createHttpClient({ baseURL: 'https://api.typeform.com' });
|
|
||||||
}
|
|
||||||
|
|
||||||
get oauthRedirectUrl() {
|
|
||||||
return this.appData.fields.find(
|
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
|
||||||
).value;
|
|
||||||
}
|
|
||||||
|
|
||||||
async createAuthData() {
|
|
||||||
const searchParams = new URLSearchParams({
|
|
||||||
client_id: this.connectionData.consumerKey as string,
|
|
||||||
redirect_uri: this.oauthRedirectUrl,
|
|
||||||
scope: this.scope.join(' '),
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = `https://api.typeform.com/oauth/authorize?${searchParams.toString()}`;
|
|
||||||
|
|
||||||
return { url };
|
|
||||||
}
|
|
||||||
|
|
||||||
async verifyCredentials() {
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
grant_type: 'authorization_code',
|
|
||||||
code: this.connectionData.oauthVerifier as string,
|
|
||||||
client_id: this.connectionData.consumerKey as string,
|
|
||||||
client_secret: this.connectionData.consumerSecret as string,
|
|
||||||
redirect_uri: this.oauthRedirectUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: verifiedCredentials } = await this.client.post(
|
|
||||||
'/oauth/token',
|
|
||||||
params.toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
|
||||||
access_token: accessToken,
|
|
||||||
expires_in: expiresIn,
|
|
||||||
token_type: tokenType,
|
|
||||||
} = verifiedCredentials;
|
|
||||||
|
|
||||||
const { data: user } = await this.client.get('/me', {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
consumerKey: this.connectionData.consumerKey,
|
|
||||||
consumerSecret: this.connectionData.consumerSecret,
|
|
||||||
accessToken,
|
|
||||||
expiresIn,
|
|
||||||
tokenType,
|
|
||||||
userId: user.user_id,
|
|
||||||
screenName: user.alias,
|
|
||||||
email: user.email,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async isStillVerified() {
|
|
||||||
try {
|
|
||||||
await this.client.get('/me', {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${this.connectionData.accessToken}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
import Authentication from './authentication';
|
|
||||||
import {
|
|
||||||
IService,
|
|
||||||
IAuthentication,
|
|
||||||
IApp,
|
|
||||||
IJSONObject,
|
|
||||||
} from '@automatisch/types';
|
|
||||||
|
|
||||||
export default class Typeform implements IService {
|
|
||||||
authenticationClient: IAuthentication;
|
|
||||||
|
|
||||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
|
||||||
this.authenticationClient = new Authentication(appData, connectionData);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,219 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Typeform",
|
|
||||||
"key": "typeform",
|
|
||||||
"iconUrl": "{BASE_URL}/apps/typeform/assets/favicon.svg",
|
|
||||||
"docUrl": "https://automatisch.io/docs/typeform",
|
|
||||||
"primaryColor": "5865f2",
|
|
||||||
"supportsConnections": true,
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"key": "oAuthRedirectUrl",
|
|
||||||
"label": "OAuth Redirect URL",
|
|
||||||
"type": "string",
|
|
||||||
"required": true,
|
|
||||||
"readOnly": true,
|
|
||||||
"value": "{WEB_APP_URL}/app/typeform/connections/add",
|
|
||||||
"placeholder": null,
|
|
||||||
"description": "When asked to input an OAuth callback or redirect URL in Typeform OAuth, enter the URL above.",
|
|
||||||
"docUrl": "https://automatisch.io/docs/typeform#oauth-redirect-url",
|
|
||||||
"clickToCopy": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "consumerKey",
|
|
||||||
"label": "Client ID",
|
|
||||||
"type": "string",
|
|
||||||
"required": true,
|
|
||||||
"readOnly": false,
|
|
||||||
"value": null,
|
|
||||||
"placeholder": null,
|
|
||||||
"description": null,
|
|
||||||
"docUrl": "https://automatisch.io/docs/typeform#consumer-key",
|
|
||||||
"clickToCopy": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "consumerSecret",
|
|
||||||
"label": "Client Secret",
|
|
||||||
"type": "string",
|
|
||||||
"required": true,
|
|
||||||
"readOnly": false,
|
|
||||||
"value": null,
|
|
||||||
"placeholder": null,
|
|
||||||
"description": null,
|
|
||||||
"docUrl": "https://automatisch.io/docs/typeform#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}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Reference in New Issue
Block a user