refactor: Generate authentication steps from auth properties
This commit is contained in:
@@ -27,42 +27,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'screenName',
|
|
||||||
value: '{fields.screenName}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'authenticationKey',
|
|
||||||
value: '{fields.authenticationKey}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -54,86 +55,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'botToken',
|
|
||||||
value: '{fields.botToken}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.code}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -14,7 +14,7 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
|||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
scope: scopes.join(' '),
|
scope: scopes.join(' '),
|
||||||
client_secret: $.auth.data.consumerSecret as string,
|
client_secret: $.auth.data.consumerSecret as string,
|
||||||
code: $.auth.data.oauthVerifier as string,
|
code: $.auth.data.code as string,
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
});
|
});
|
||||||
const { data: verifiedCredentials } = await $.http.post(
|
const { data: verifiedCredentials } = await $.http.post(
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -42,82 +43,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.oauth_verifier}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -3,7 +3,7 @@ import { URLSearchParams } from 'url';
|
|||||||
|
|
||||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||||
const response = await $.http.post(
|
const response = await $.http.post(
|
||||||
`/oauth/access_token?oauth_verifier=${$.auth.data.oauthVerifier}&oauth_token=${$.auth.data.accessToken}`,
|
`/oauth/access_token?oauth_verifier=${$.auth.data.oauth_verifier}&oauth_token=${$.auth.data.accessToken}`,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -42,82 +43,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.code}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -7,7 +7,7 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
|||||||
{
|
{
|
||||||
client_id: $.auth.data.consumerKey,
|
client_id: $.auth.data.consumerKey,
|
||||||
client_secret: $.auth.data.consumerSecret,
|
client_secret: $.auth.data.consumerSecret,
|
||||||
code: $.auth.data.oauthVerifier,
|
code: $.auth.data.code,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -60,91 +61,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
step: 1,
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauth2Url',
|
|
||||||
value: '{fields.oauth2Url}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
step: 2,
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
step: 3,
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
step: 4,
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'code',
|
|
||||||
value: '{openAuthPopup.code}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
step: 5,
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -39,86 +40,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'code',
|
|
||||||
value: '{openAuthPopup.code}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'state',
|
|
||||||
value: '{openAuthPopup.state}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -86,58 +86,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'host',
|
|
||||||
value: '{fields.host}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'username',
|
|
||||||
value: '{fields.username}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'password',
|
|
||||||
value: '{fields.password}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'useTLS',
|
|
||||||
value: '{fields.useTls}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'port',
|
|
||||||
value: '{fields.port}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'fromEmail',
|
|
||||||
value: '{fields.fromEmail}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -27,42 +27,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'accountSid',
|
|
||||||
value: '{fields.accountSid}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'authToken',
|
|
||||||
value: '{fields.authToken}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
|
@@ -3,6 +3,7 @@ import verifyCredentials from './verify-credentials';
|
|||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
generateAuthUrl: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
key: 'oAuthRedirectUrl',
|
key: 'oAuthRedirectUrl',
|
||||||
@@ -39,76 +40,6 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: '{key}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: '{openAuthPopup.all}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{createConnection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
101
packages/backend/src/helpers/add-authentication-steps.ts
Normal file
101
packages/backend/src/helpers/add-authentication-steps.ts
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import { IApp } from '@automatisch/types';
|
||||||
|
|
||||||
|
function addAuthenticationSteps(app: IApp): IApp {
|
||||||
|
if (app.auth.generateAuthUrl) {
|
||||||
|
app.auth.authenticationSteps = authenticationStepsWithAuthUrl;
|
||||||
|
} else {
|
||||||
|
app.auth.authenticationSteps = authenticationStepsWithoutAuthUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
const authenticationStepsWithoutAuthUrl = [
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'createConnection',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: '{key}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'formattedData',
|
||||||
|
value: '{fields.all}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'verifyConnection',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
value: '{createConnection.id}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const authenticationStepsWithAuthUrl = [
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'createConnection',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: '{key}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'formattedData',
|
||||||
|
value: '{fields.all}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'createAuthData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
value: '{createConnection.id}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'openWithPopup' as const,
|
||||||
|
name: 'openAuthPopup',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'url',
|
||||||
|
value: '{createAuthData.url}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'updateConnection',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
value: '{createConnection.id}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'formattedData',
|
||||||
|
value: '{openAuthPopup.all}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'verifyConnection',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
value: '{createConnection.id}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default addAuthenticationSteps;
|
@@ -8,14 +8,12 @@ import {
|
|||||||
ITrigger,
|
ITrigger,
|
||||||
} from '@automatisch/types';
|
} from '@automatisch/types';
|
||||||
import { omit, cloneDeep } from 'lodash';
|
import { omit, cloneDeep } from 'lodash';
|
||||||
|
import addAuthenticationSteps from './add-authentication-steps';
|
||||||
import addReconnectionSteps from './add-reconnection-steps';
|
import addReconnectionSteps from './add-reconnection-steps';
|
||||||
|
|
||||||
type TApps = Record<string, Promise<{ default: IApp }>>;
|
type TApps = Record<string, Promise<{ default: IApp }>>;
|
||||||
const apps = fs
|
const apps = fs
|
||||||
.readdirSync(
|
.readdirSync(path.resolve(__dirname, `../apps/`), { withFileTypes: true })
|
||||||
path.resolve(__dirname, `../apps/`),
|
|
||||||
{ withFileTypes: true }
|
|
||||||
)
|
|
||||||
.reduce((apps, dirent) => {
|
.reduce((apps, dirent) => {
|
||||||
if (!dirent.isDirectory()) return apps;
|
if (!dirent.isDirectory()) return apps;
|
||||||
|
|
||||||
@@ -36,6 +34,7 @@ const getApp = async (appKey: string, stripFuncs = true) => {
|
|||||||
let appData: IApp = cloneDeep(await getDefaultExport(appKey));
|
let appData: IApp = cloneDeep(await getDefaultExport(appKey));
|
||||||
|
|
||||||
if (appData.auth) {
|
if (appData.auth) {
|
||||||
|
appData = addAuthenticationSteps(appData);
|
||||||
appData = addReconnectionSteps(appData);
|
appData = addReconnectionSteps(appData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
packages/types/index.d.ts
vendored
3
packages/types/index.d.ts
vendored
@@ -181,8 +181,9 @@ export interface IAuth {
|
|||||||
createAuthData?($: IGlobalVariable): Promise<void>;
|
createAuthData?($: IGlobalVariable): Promise<void>;
|
||||||
verifyCredentials($: IGlobalVariable): Promise<any>;
|
verifyCredentials($: IGlobalVariable): Promise<any>;
|
||||||
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
||||||
|
generateAuthUrl?: boolean;
|
||||||
fields: IField[];
|
fields: IField[];
|
||||||
authenticationSteps: IAuthenticationStep[];
|
authenticationSteps?: IAuthenticationStep[];
|
||||||
reconnectionSteps?: IAuthenticationStep[];
|
reconnectionSteps?: IAuthenticationStep[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user