diff --git a/packages/api/src/@core/utils/crypto.ts b/packages/api/src/@core/utils/crypto.ts index 95d297b96..89dbdfa31 100644 --- a/packages/api/src/@core/utils/crypto.ts +++ b/packages/api/src/@core/utils/crypto.ts @@ -39,3 +39,24 @@ export function decrypt(encryptedData: string): string { throw new Error('Decrypting error... ' + error); } } + +export function decryptTwo(encryptedData: Buffer): string { + try { + const dataString = encryptedData.toString('utf-8'); + const textParts = dataString.split(':'); + // Extract the IV from the first half of the value + const ivFromText = Buffer.from(textParts.shift() as string, 'hex'); + // Extract the encrypted text without the IV + const encryptedText = textParts.join(':'); + const decipher = crypto.createDecipheriv( + 'aes-256-cbc', + Buffer.from(secretKey), + ivFromText, + ); + let decrypted = decipher.update(encryptedText, 'hex', 'utf8'); + decrypted += decipher.final('utf8'); + return decrypted; + } catch (error) { + throw new Error('Decrypting error... ' + error); + } +} diff --git a/packages/api/src/app.service.ts b/packages/api/src/app.service.ts index 257ce8cde..bbc6e1ff8 100644 --- a/packages/api/src/app.service.ts +++ b/packages/api/src/app.service.ts @@ -1,8 +1,14 @@ +import { decrypt, decryptTwo } from '@@core/utils/crypto'; import { Injectable } from '@nestjs/common'; @Injectable() export class AppService { getHello(): string { + console.log('*********************'); + console.log(process.env.REFRESH_TEST); + console.log(decryptTwo(Buffer.from(process.env.REFRESH_TEST || '', 'utf-8'))); + console.log('*********************'); + return 'Hello You Are On The Panora API!'; } } diff --git a/packages/api/src/crm/contact/contact.controller.ts b/packages/api/src/crm/contact/contact.controller.ts index 9df49bb89..c16a3271f 100644 --- a/packages/api/src/crm/contact/contact.controller.ts +++ b/packages/api/src/crm/contact/contact.controller.ts @@ -70,9 +70,9 @@ export class ContactController { summary: 'Create CRM Contact', description: 'Create a contact in any supported CRM', }) - @ApiQuery({ name: 'integrationId', required: true, type: String }) - @ApiQuery({ name: 'linkedUserId', required: true, type: String }) - @ApiQuery({ name: 'remote_data', required: false, type: Boolean }) + @ApiQuery({ name: 'integrationId', required: true, type: String, description: 'The integration ID', example: '6aa2acf3-c244-4f85-848b-13a57e7abf55' }) + @ApiQuery({ name: 'linkedUserId', required: true, type: String, description: 'The linked user ID', example: 'b008e199-eda9-4629-bd41-a01b6195864a' }) + @ApiQuery({ name: 'remote_data', required: false, type: Boolean, description: 'Set to true to include data from the original CRM software.' }) @ApiBody({ type: UnifiedContactInput }) @ApiCustomResponse(ContactResponse) @Post() diff --git a/packages/api/src/crm/contact/types/model.unified.ts b/packages/api/src/crm/contact/types/model.unified.ts index 3e2dc41c0..e8004d954 100644 --- a/packages/api/src/crm/contact/types/model.unified.ts +++ b/packages/api/src/crm/contact/types/model.unified.ts @@ -2,9 +2,9 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Email, Phone } from '.'; export class UnifiedContactInput { - @ApiProperty() + @ApiProperty({ description: 'The first name of the contact' }) first_name: string; - @ApiProperty() + @ApiProperty({ description: 'The last name of the contact' }) last_name: string; @ApiProperty({ type: [Email] }) email_addresses: Email[]; diff --git a/packages/api/swagger/swagger-spec.json b/packages/api/swagger/swagger-spec.json index bab393170..8eeb584fc 100644 --- a/packages/api/swagger/swagger-spec.json +++ b/packages/api/swagger/swagger-spec.json @@ -699,6 +699,8 @@ "name": "integrationId", "required": true, "in": "query", + "description": "The integration ID", + "example": "6aa2acf3-c244-4f85-848b-13a57e7abf55", "schema": { "type": "string" } @@ -707,6 +709,8 @@ "name": "linkedUserId", "required": true, "in": "query", + "description": "The linked user ID", + "example": "b008e199-eda9-4629-bd41-a01b6195864a", "schema": { "type": "string" } @@ -715,6 +719,7 @@ "name": "remote_data", "required": false, "in": "query", + "description": "Set to true to include data from the original CRM software.", "schema": { "type": "boolean" } @@ -984,7 +989,10 @@ "type": "string" }, "scope": { - "type": "string" + "type": "array", + "items": { + "type": "string" + } } }, "required": [ @@ -1239,10 +1247,12 @@ "type": "object", "properties": { "first_name": { - "type": "string" + "type": "string", + "description": "The first name of the contact" }, "last_name": { - "type": "string" + "type": "string", + "description": "The last name of the contact" }, "email_addresses": { "type": "array",