Skip to content
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
69 changes: 3 additions & 66 deletions api/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import regionConfig = require('./region-config.json');

export const CS_REGIONS = [
'NA',
'EU',
Expand Down Expand Up @@ -330,69 +332,4 @@ export const RESERVED_FIELD_MAPPINGS: Record<string, string> = {
export const MEDIA_BLOCK_NAMES = ['core/image', 'core/video', 'core/audio', 'core/file'];
export const WORDPRESS_MISSSING_BLOCKS = 'core/missing';

// Region configuration
export const REGION_CONFIG = {
NA: {
name: "North America",
cma: "https://api.contentstack.io",
cda: "https://cdn.contentstack.io",
app: "https://app.contentstack.com",
developerHub: "https://developerhub-api.contentstack.com",
personalize: "https://personalize-api.contentstack.com",
launch: "https://launch-api.contentstack.com",
},
EU: {
name: "Europe",
cma: "https://eu-api.contentstack.com",
cda: "https://eu-cdn.contentstack.com",
app: "https://eu-app.contentstack.com",
developerHub: "https://eu-developerhub-api.contentstack.com",
personalize: "https://eu-personalize-api.contentstack.com",
launch: "https://eu-launch-api.contentstack.com",
},
"AZURE-NA": {
name: "Azure North America",
cma: "https://azure-na-api.contentstack.com",
cda: "https://azure-na-cdn.contentstack.com",
app: "https://azure-na-app.contentstack.com",
developerHub: "https://azure-na-developerhub-api.contentstack.com",
personalize: "https://azure-na-personalize-api.contentstack.com",
launch: "https://azure-na-launch-api.contentstack.com",
},
"AZURE-EU": {
name: "Azure Europe",
cma: "https://azure-eu-api.contentstack.com",
cda: "https://azure-eu-cdn.contentstack.com",
app: "https://azure-eu-app.contentstack.com",
developerHub: "https://azure-eu-developerhub-api.contentstack.com",
personalize: "https://azure-eu-personalize-api.contentstack.com",
launch: "https://azure-eu-launch-api.contentstack.com",
},
"GCP-NA": {
name: "GCP North America",
cma: "https://gcp-na-api.contentstack.com",
cda: "https://gcp-na-cdn.contentstack.com",
app: "https://gcp-na-app.contentstack.com",
developerHub: "https://gcp-na-developerhub-api.contentstack.com",
personalize: "https://gcp-na-personalize-api.contentstack.com",
launch: "https://gcp-na-launch-api.contentstack.com",
},
"GCP-EU": {
name: "GCP Europe",
cma: "https://gcp-eu-api.contentstack.com",
cda: "https://gcp-eu-cdn.contentstack.com",
app: "https://gcp-eu-app.contentstack.com",
developerHub: "https://gcp-eu-developerhub-api.contentstack.com",
personalize: "https://gcp-eu-personalize-api.contentstack.com",
launch: "https://gcp-eu-launch-api.contentstack.com",
},
"AU": {
name: "Australia",
cma: "https://au-api.contentstack.com",
cda: "https://au-cdn.contentstack.com",
app: "https://au-app.contentstack.com",
developerHub: "https://au-developerhub-api.contentstack.com",
personalize: "https://au-personalize-api.contentstack.com",
launch: "https://au-launch-api.contentstack.com",
},
};
export const REGION_CONFIG = regionConfig;
65 changes: 65 additions & 0 deletions api/src/constants/region-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"NA": {
"name": "North America",
"cma": "https://api.contentstack.io",
"cda": "https://cdn.contentstack.io",
"app": "https://app.contentstack.com",
"developerHub": "https://developerhub-api.contentstack.com",
"personalize": "https://personalize-api.contentstack.com",
"launch": "https://launch-api.contentstack.com"
},
"EU": {
"name": "Europe",
"cma": "https://eu-api.contentstack.com",
"cda": "https://eu-cdn.contentstack.com",
"app": "https://eu-app.contentstack.com",
"developerHub": "https://eu-developerhub-api.contentstack.com",
"personalize": "https://eu-personalize-api.contentstack.com",
"launch": "https://eu-launch-api.contentstack.com"
},
"AZURE-NA": {
"name": "Azure North America",
"cma": "https://azure-na-api.contentstack.com",
"cda": "https://azure-na-cdn.contentstack.com",
"app": "https://azure-na-app.contentstack.com",
"developerHub": "https://azure-na-developerhub-api.contentstack.com",
"personalize": "https://azure-na-personalize-api.contentstack.com",
"launch": "https://azure-na-launch-api.contentstack.com"
},
"AZURE-EU": {
"name": "Azure Europe",
"cma": "https://azure-eu-api.contentstack.com",
"cda": "https://azure-eu-cdn.contentstack.com",
"app": "https://azure-eu-app.contentstack.com",
"developerHub": "https://azure-eu-developerhub-api.contentstack.com",
"personalize": "https://azure-eu-personalize-api.contentstack.com",
"launch": "https://azure-eu-launch-api.contentstack.com"
},
"GCP-NA": {
"name": "GCP North America",
"cma": "https://gcp-na-api.contentstack.com",
"cda": "https://gcp-na-cdn.contentstack.com",
"app": "https://gcp-na-app.contentstack.com",
"developerHub": "https://gcp-na-developerhub-api.contentstack.com",
"personalize": "https://gcp-na-personalize-api.contentstack.com",
"launch": "https://gcp-na-launch-api.contentstack.com"
},
"GCP-EU": {
"name": "GCP Europe",
"cma": "https://gcp-eu-api.contentstack.com",
"cda": "https://gcp-eu-cdn.contentstack.com",
"app": "https://gcp-eu-app.contentstack.com",
"developerHub": "https://gcp-eu-developerhub-api.contentstack.com",
"personalize": "https://gcp-eu-personalize-api.contentstack.com",
"launch": "https://gcp-eu-launch-api.contentstack.com"
},
"AU": {
"name": "Australia",
"cma": "https://au-api.contentstack.com",
"cda": "https://au-cdn.contentstack.com",
"app": "https://au-app.contentstack.com",
"developerHub": "https://au-developerhub-api.contentstack.com",
"personalize": "https://au-personalize-api.contentstack.com",
"launch": "https://au-launch-api.contentstack.com"
}
}
6 changes: 2 additions & 4 deletions api/sso.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const crypto = require("crypto");
const rawManifest = require("./manifest.json");
const { default: axios } = require("axios");
const dotenv = require("dotenv");
const { REGION_CONFIG } = require("./src/constants/index");
const REGION_CONFIG = require("./src/constants/region-config.json");
dotenv.config();

const ENCRYPT_KEY = process.env?.MANIFEST_ENCRYPT_KEY;
Expand All @@ -25,7 +25,7 @@ function encrypt(plaintext) {
const authTag = cipher?.getAuthTag()?.toString("hex");
return `${ENC_PREFIX}${iv?.toString("hex")}:${authTag}:${encrypted}`;
}

function decrypt(encryptedValue) {
if (!encryptedValue || !encryptedValue?.startsWith(ENC_PREFIX)) return encryptedValue;
if (!ENCRYPT_KEY) throw new Error("MANIFEST_ENCRYPT_KEY env variable is required to decrypt manifest credentials");
Expand All @@ -50,8 +50,6 @@ function decryptManifest(m) {

const manifest = decryptManifest(rawManifest);



/**
* Gets the current region from the CSDX config.
* @returns The current region.
Expand Down
Loading