Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Update docs #185

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/api/src/@core/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 6 additions & 0 deletions packages/api/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -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!';
}
}
6 changes: 3 additions & 3 deletions packages/api/src/crm/contact/contact.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/crm/contact/types/model.unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
16 changes: 13 additions & 3 deletions packages/api/swagger/swagger-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"name": "integrationId",
"required": true,
"in": "query",
"description": "The integration ID",
"example": "6aa2acf3-c244-4f85-848b-13a57e7abf55",
"schema": {
"type": "string"
}
Expand All @@ -707,6 +709,8 @@
"name": "linkedUserId",
"required": true,
"in": "query",
"description": "The linked user ID",
"example": "b008e199-eda9-4629-bd41-a01b6195864a",
"schema": {
"type": "string"
}
Expand All @@ -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"
}
Expand Down Expand Up @@ -984,7 +989,10 @@
"type": "string"
},
"scope": {
"type": "string"
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
Expand Down Expand Up @@ -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",
Expand Down
Loading