Merge pull request #704 from automatisch/expand-auth-arguments
feat: add .all support in auth arguments
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,
|
||||||
|
@@ -2,7 +2,7 @@ import { IField, IGlobalVariable } from '@automatisch/types';
|
|||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
import scopes from '../common/scopes';
|
import scopes from '../common/scopes';
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -54,88 +54,8 @@ 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,
|
generateAuthUrl,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -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(
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -42,84 +42,7 @@ export default {
|
|||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
generateAuthUrl,
|
||||||
{
|
|
||||||
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,
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const scopes = ['read:org', 'repo', 'user'];
|
const scopes = ['read:org', 'repo', 'user'];
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -42,84 +42,8 @@ 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,
|
generateAuthUrl,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -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: {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -60,93 +60,8 @@ 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,
|
generateAuthUrl,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -42,7 +42,7 @@ const userScopes = [
|
|||||||
'users:read.email',
|
'users:read.email',
|
||||||
];
|
];
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -39,88 +39,8 @@ 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,
|
generateAuthUrl,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -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,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
export default async function createAuthData($: IGlobalVariable) {
|
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
@@ -1,4 +1,4 @@
|
|||||||
import createAuthData from './create-auth-data';
|
import generateAuthUrl from './generate-auth-url';
|
||||||
import verifyCredentials from './verify-credentials';
|
import verifyCredentials from './verify-credentials';
|
||||||
import isStillVerified from './is-still-verified';
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
@@ -39,84 +39,8 @@ 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,
|
generateAuthUrl,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { IJSONObject } from '@automatisch/types';
|
import { IJSONObject } from '@automatisch/types';
|
||||||
import BaseError from './base';
|
import BaseError from './base';
|
||||||
|
|
||||||
export default class CreateAuthDataError extends BaseError {
|
export default class GenerateAuthUrlError extends BaseError {
|
||||||
constructor(error: IJSONObject) {
|
constructor(error: IJSONObject) {
|
||||||
const computedError =
|
const computedError =
|
||||||
((error.response as IJSONObject)?.data as IJSONObject) ||
|
((error.response as IJSONObject)?.data as IJSONObject) ||
|
@@ -1,5 +1,5 @@
|
|||||||
import createConnection from './mutations/create-connection';
|
import createConnection from './mutations/create-connection';
|
||||||
import createAuthData from './mutations/create-auth-data';
|
import generateAuthUrl from './mutations/generate-auth-url';
|
||||||
import updateConnection from './mutations/update-connection';
|
import updateConnection from './mutations/update-connection';
|
||||||
import resetConnection from './mutations/reset-connection';
|
import resetConnection from './mutations/reset-connection';
|
||||||
import verifyConnection from './mutations/verify-connection';
|
import verifyConnection from './mutations/verify-connection';
|
||||||
@@ -17,7 +17,7 @@ import login from './mutations/login';
|
|||||||
|
|
||||||
const mutationResolvers = {
|
const mutationResolvers = {
|
||||||
createConnection,
|
createConnection,
|
||||||
createAuthData,
|
generateAuthUrl,
|
||||||
updateConnection,
|
updateConnection,
|
||||||
resetConnection,
|
resetConnection,
|
||||||
verifyConnection,
|
verifyConnection,
|
||||||
|
@@ -2,7 +2,7 @@ import Context from '../../types/express/context';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import globalVariable from '../../helpers/global-variable';
|
import globalVariable from '../../helpers/global-variable';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
import CreateAuthDataError from '../../errors/create-auth-data';
|
import GenerateAuthUrlError from '../../errors/generate-auth-url';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
input: {
|
input: {
|
||||||
@@ -10,7 +10,7 @@ type Params = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAuthData = async (
|
const generateAuthUrl = async (
|
||||||
_parent: unknown,
|
_parent: unknown,
|
||||||
params: Params,
|
params: Params,
|
||||||
context: Context
|
context: Context
|
||||||
@@ -32,13 +32,13 @@ const createAuthData = async (
|
|||||||
|
|
||||||
const $ = await globalVariable({ connection, app });
|
const $ = await globalVariable({ connection, app });
|
||||||
try {
|
try {
|
||||||
await authInstance.createAuthData($);
|
await authInstance.generateAuthUrl($);
|
||||||
await axios.get(connection.formattedData.url as string);
|
await axios.get(connection.formattedData.url as string);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new CreateAuthDataError(error);
|
throw new GenerateAuthUrlError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection.formattedData;
|
return connection.formattedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createAuthData;
|
export default generateAuthUrl;
|
@@ -30,7 +30,7 @@ type Query {
|
|||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
createConnection(input: CreateConnectionInput): Connection
|
createConnection(input: CreateConnectionInput): Connection
|
||||||
createAuthData(input: CreateAuthDataInput): AuthLink
|
generateAuthUrl(input: GenerateAuthUrlInput): AuthLink
|
||||||
updateConnection(input: UpdateConnectionInput): Connection
|
updateConnection(input: UpdateConnectionInput): Connection
|
||||||
resetConnection(input: ResetConnectionInput): Connection
|
resetConnection(input: ResetConnectionInput): Connection
|
||||||
verifyConnection(input: VerifyConnectionInput): Connection
|
verifyConnection(input: VerifyConnectionInput): Connection
|
||||||
@@ -225,7 +225,7 @@ input CreateConnectionInput {
|
|||||||
formattedData: JSONObject!
|
formattedData: JSONObject!
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateAuthDataInput {
|
input GenerateAuthUrlInput {
|
||||||
id: String!
|
id: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: 'generateAuthUrl',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
value: '{createConnection.id}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'openWithPopup' as const,
|
||||||
|
name: 'openAuthPopup',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'url',
|
||||||
|
value: '{generateAuthUrl.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
packages/types/index.d.ts
vendored
4
packages/types/index.d.ts
vendored
@@ -178,11 +178,11 @@ export interface IData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IAuth {
|
export interface IAuth {
|
||||||
createAuthData?($: IGlobalVariable): Promise<void>;
|
generateAuthUrl?($: IGlobalVariable): Promise<void>;
|
||||||
verifyCredentials($: IGlobalVariable): Promise<any>;
|
verifyCredentials($: IGlobalVariable): Promise<any>;
|
||||||
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
||||||
fields: IField[];
|
fields: IField[];
|
||||||
authenticationSteps: IAuthenticationStep[];
|
authenticationSteps?: IAuthenticationStep[];
|
||||||
reconnectionSteps?: IAuthenticationStep[];
|
reconnectionSteps?: IAuthenticationStep[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
|
|
||||||
export const CREATE_AUTH_DATA = gql`
|
|
||||||
mutation CreateAuthData($input: CreateAuthDataInput) {
|
|
||||||
createAuthData(input: $input) {
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
9
packages/web/src/graphql/mutations/generate-auth-url.ts
Normal file
9
packages/web/src/graphql/mutations/generate-auth-url.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
export const GENERATE_AUTH_URL = gql`
|
||||||
|
mutation generateAuthUrl($input: GenerateAuthUrlInput) {
|
||||||
|
generateAuthUrl(input: $input) {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
@@ -3,7 +3,7 @@ import { UPDATE_CONNECTION } from './update-connection';
|
|||||||
import { VERIFY_CONNECTION } from './verify-connection';
|
import { VERIFY_CONNECTION } from './verify-connection';
|
||||||
import { RESET_CONNECTION } from './reset-connection';
|
import { RESET_CONNECTION } from './reset-connection';
|
||||||
import { DELETE_CONNECTION } from './delete-connection';
|
import { DELETE_CONNECTION } from './delete-connection';
|
||||||
import { CREATE_AUTH_DATA } from './create-auth-data';
|
import { GENERATE_AUTH_URL } from './generate-auth-url';
|
||||||
|
|
||||||
type Mutations = {
|
type Mutations = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
@@ -15,7 +15,7 @@ const mutations: Mutations = {
|
|||||||
verifyConnection: VERIFY_CONNECTION,
|
verifyConnection: VERIFY_CONNECTION,
|
||||||
resetConnection: RESET_CONNECTION,
|
resetConnection: RESET_CONNECTION,
|
||||||
deleteConnection: DELETE_CONNECTION,
|
deleteConnection: DELETE_CONNECTION,
|
||||||
createAuthData: CREATE_AUTH_DATA,
|
generateAuthUrl: GENERATE_AUTH_URL,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default mutations;
|
export default mutations;
|
||||||
|
@@ -27,6 +27,13 @@ const computeAuthStepVariables = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variable.value) {
|
if (variable.value) {
|
||||||
|
if (variable.value.endsWith('.all}')) {
|
||||||
|
const key = variable.value.replace('{', '').replace('.all}', '');
|
||||||
|
variables[variable.name] = aggregatedData[key];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const computedVariable = template(variable.value, { interpolate })(
|
const computedVariable = template(variable.value, { interpolate })(
|
||||||
aggregatedData
|
aggregatedData
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user