mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-10 12:34:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aaf99b8c2e | ||
|
|
8060cd769f | ||
|
|
89eed11561 | ||
|
|
0895922b1c | ||
|
|
1cc094d40b | ||
|
|
d13aa2b72a | ||
|
|
a98ec4bf32 | ||
|
|
d5b1cb51b4 | ||
|
|
5d3510639e |
Generated
+534
-528
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -46,6 +46,7 @@
|
||||
"jwk-to-pem": "^2.0.5",
|
||||
"passport": "^0.6.0",
|
||||
"passport-facebook": "^3.0.0",
|
||||
"passport-forcedotcom": "^0.1.5",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
@@ -65,11 +66,11 @@
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@types/jwk-to-pem": "^2.0.1",
|
||||
"@types/multer": "^1.4.7",
|
||||
"@types/node": "^16.11.41",
|
||||
"@types/passport-facebook": "^2.1.11",
|
||||
"@types/passport-google-oauth20": "^2.0.11",
|
||||
"@types/passport-oauth2": "^1.4.11",
|
||||
"@types/multer": "^1.4.7",
|
||||
"@types/supertest": "^2.0.12",
|
||||
"@typescript-eslint/eslint-plugin": "^5.29.0",
|
||||
"@typescript-eslint/parser": "^5.29.0",
|
||||
|
||||
+2
-4
@@ -37,6 +37,7 @@ import { AuthenticationGuard } from './authentication/authentication.guard';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { GoogleStrategy } from './modules/oauth/passport-strategies/google-strategy';
|
||||
import { MailChimpStrategy } from './modules/oauth/passport-strategies/mailchimp-strategy';
|
||||
import { SalesforceStrategy } from './modules/oauth/passport-strategies/salesforce-strategy';
|
||||
import { ConnectorClientConfiguration } from './clients/connector/client.config';
|
||||
import { ConnectorController } from './modules/connector/connector.controller';
|
||||
import { ConnectorClientService } from './clients/connector/client.service';
|
||||
@@ -75,14 +76,11 @@ const connectorClient = new ConnectorClientConfiguration();
|
||||
AuthClientService,
|
||||
PermissionsClientService,
|
||||
CatalogService,
|
||||
{
|
||||
provide: APP_GUARD,
|
||||
useClass: AuthenticationGuard,
|
||||
},
|
||||
HubspotStrategy,
|
||||
FacebookStrategy,
|
||||
GoogleStrategy,
|
||||
MailChimpStrategy,
|
||||
SalesforceStrategy,
|
||||
{
|
||||
provide: APP_GUARD,
|
||||
useClass: AuthenticationGuard,
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { writeFileSync } from 'fs';
|
||||
import helmet from 'helmet';
|
||||
|
||||
import documentEmpty from '../swagger_empty.json';
|
||||
@@ -27,7 +26,7 @@ async function bootstrap() {
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
writeFileSync('./swagger.json', JSON.stringify(document));
|
||||
|
||||
if (process.env.ENV != 'stg' && process.env.ENV != 'prd')
|
||||
SwaggerModule.setup('api', app, document);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ export class ConnectorController {
|
||||
async getAllConnectors(@Query() queries: GetAllDto) {
|
||||
console.log(`/upload`, 'Upload Connector Route');
|
||||
|
||||
const { filters, search } = queries;
|
||||
const { search, ...filters } = queries;
|
||||
|
||||
const response: any = await this.connectorClientService.getAllConnectors({
|
||||
filters: filters || {},
|
||||
|
||||
@@ -5,5 +5,5 @@ export class GetAllDto {
|
||||
search: string;
|
||||
|
||||
@ApiProperty()
|
||||
filters: object;
|
||||
filters: any;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,19 @@ export class OauthController {
|
||||
return await this.callback(req, 'mailchimp');
|
||||
}
|
||||
|
||||
@Get('salesforce')
|
||||
@UseGuards(AuthGuard('salesforce'))
|
||||
async oauthSalesforce() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Get('salesforce/callback')
|
||||
@UseGuards(AuthGuard('salesforce'))
|
||||
@Redirect()
|
||||
async oauthSalesforceCallback(@Req() req) {
|
||||
return await this.callback(req, 'salesforce');
|
||||
}
|
||||
|
||||
async callback(@Req() req: Request, plugin) {
|
||||
const { error, state: customer_id } = req.query;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
clientID: oauthSecrets.hubspot.client_id,
|
||||
clientSecret: oauthSecrets.hubspot.client_secret,
|
||||
callbackURL: oauthSecrets.hubspot.redirect_uri,
|
||||
redirectUri: oauthSecrets.hubspot.redirect_uri,
|
||||
scope:
|
||||
'automation business-intelligence oauth forms integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read',
|
||||
passReqToCallback: true,
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Strategy } from 'passport-forcedotcom';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { OauthSecrets } from 'src/utils/OauthSecrets';
|
||||
|
||||
@Injectable()
|
||||
export class SalesforceStrategy extends PassportStrategy(
|
||||
Strategy,
|
||||
'salesforce',
|
||||
) {
|
||||
constructor(
|
||||
@Inject('OAUTH_SECRETS')
|
||||
private readonly oauthSecrets: OauthSecrets,
|
||||
) {
|
||||
const options = {
|
||||
clientID: oauthSecrets.salesforce.client_id,
|
||||
clientSecret: oauthSecrets.salesforce.client_secret,
|
||||
callbackURL: oauthSecrets.salesforce.redirect_uri,
|
||||
scope: [
|
||||
'wave_api',
|
||||
'chatter_api',
|
||||
'chatbot_api',
|
||||
'cdp_ingest_api',
|
||||
'cdp_profile_api',
|
||||
'api',
|
||||
'pardot_api',
|
||||
'cdp_segment_api',
|
||||
'cdp_query_api',
|
||||
'refresh_token',
|
||||
'offline_access',
|
||||
],
|
||||
};
|
||||
const verify = ({ params }, refreshToken: string, profile: any, done) => {
|
||||
return done(null, profile, {
|
||||
accessToken: params.access_token,
|
||||
refreshToken,
|
||||
});
|
||||
};
|
||||
super(options, verify);
|
||||
}
|
||||
|
||||
authenticate(req, options) {
|
||||
const { customer_id } = req.query;
|
||||
options.state = customer_id;
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ export class OauthSecrets {
|
||||
google = new OauthSecretsObject();
|
||||
mailchimp = new OauthSecretsObject();
|
||||
facebook = new OauthSecretsObject();
|
||||
salesforce = new OauthSecretsObject();
|
||||
}
|
||||
export async function getOauthSecrets() {
|
||||
const secrets = new OauthSecrets();
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user