Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/panoratech/Panora into feat…
Browse files Browse the repository at this point in the history
…/amazon-integration
  • Loading branch information
naelob committed Aug 10, 2024
2 parents f72884f + 84d7bea commit c859a93
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/api/scripts/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ CREATE TABLE connector_sets
crm_zendesk boolean NULL,
crm_close boolean NULL,
fs_box boolean NULL,
tcg_github boolean NULL,
tcg_github boolean NULL,
ecom_woocommerce boolean NULL,
ecom_shopify boolean NULL,
CONSTRAINT PK_project_connector PRIMARY KEY ( id_connector_set )
);

Expand Down
8 changes: 8 additions & 0 deletions packages/api/src/@core/connections/connections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class ConnectionsController {
async handleOAuthCallback(@Res() res: Response, @Query() query: any) {
try {
const { state, code, ...otherParams } = query;

if (!code) {
throw new ConnectionsError({
name: 'OAUTH_CALLBACK_CODE_NOT_FOUND_ERROR',
Expand All @@ -93,6 +94,13 @@ export class ConnectionsController {
// Step 3: Parse the JSON
stateData = JSON.parse(decodedState);
console.log(stateData);
} else if (state.includes(':')) {
// squarespace asks for a random alphanumeric value
// Split the random part and the base64 part
const [randomPart, base64Part] = decodeURIComponent(state).split(':');
// Decode the base64 part to get the original JSON
const jsonString = Buffer.from(base64Part, 'base64').toString('utf-8');
stateData = JSON.parse(jsonString);
} else {
// If no HTML entities are present, parse directly
stateData = JSON.parse(state);
Expand Down
12 changes: 11 additions & 1 deletion packages/shared/src/authUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ export const constructAuthUrl = async ({ projectId, linkedUserId, providerName,
if (providerName === 'microsoftdynamicssales') {
state = encodeURIComponent(JSON.stringify({ projectId, linkedUserId, providerName, vertical, returnUrl, resource: additionalParams!.end_user_domain }));
}

if(providerName === 'squarespace'){
const randomState = randomString();
state = encodeURIComponent(randomState + ':' + Buffer.from(JSON.stringify({
projectId,
linkedUserId,
providerName,
vertical,
returnUrl,
resource: additionalParams.end_user_domain
})).toString('base64'));
}
// console.log('State : ', JSON.stringify({ projectId, linkedUserId, providerName, vertical, returnUrl }));
// console.log('encodedRedirect URL : ', encodedRedirectUrl);
// const vertical = findConnectorCategory(providerName);
Expand Down

0 comments on commit c859a93

Please sign in to comment.