feat: introduce app configs with shared auth clients (#1213)

This commit is contained in:
Ali BARIN
2023-08-16 15:46:43 +02:00
committed by GitHub
parent 25983e046c
commit 3b54b29a99
47 changed files with 1504 additions and 113 deletions

View File

@@ -3,6 +3,7 @@ import { IApp } from '@automatisch/types';
function addAuthenticationSteps(app: IApp): IApp {
if (app.auth.generateAuthUrl) {
app.auth.authenticationSteps = authenticationStepsWithAuthUrl;
app.auth.sharedAuthenticationSteps = sharedAuthenticationStepsWithAuthUrl;
} else {
app.auth.authenticationSteps = authenticationStepsWithoutAuthUrl;
}
@@ -98,4 +99,65 @@ const authenticationStepsWithAuthUrl = [
},
];
const sharedAuthenticationStepsWithAuthUrl = [
{
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
name: 'key',
value: '{key}',
},
{
name: 'appAuthClientId',
value: '{appAuthClientId}',
},
],
},
{
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;

View File

@@ -67,11 +67,21 @@ function addReconnectionSteps(app: IApp): IApp {
if (hasReconnectionSteps) return app;
const updatedSteps = replaceCreateConnectionsWithUpdate(
app.auth.authenticationSteps
);
if (app.auth.authenticationSteps) {
const updatedSteps = replaceCreateConnectionsWithUpdate(
app.auth.authenticationSteps
);
app.auth.reconnectionSteps = [resetConnectionStep, ...updatedSteps];
app.auth.reconnectionSteps = [resetConnectionStep, ...updatedSteps];
}
if (app.auth.sharedAuthenticationSteps) {
const updatedStepsWithEmbeddedDefaults = replaceCreateConnectionsWithUpdate(
app.auth.sharedAuthenticationSteps
);
app.auth.sharedReconnectionSteps = [resetConnectionStep, ...updatedStepsWithEmbeddedDefaults];
}
return app;
}