{
  "slug": "hide-salesforce-credentials-javascript",
  "title": "Hide salesforce api credentials in javascript client app",
  "metaTitle": "Hide salesforce api credentials in - RealComposer",
  "metaDescription": "Hide salesforce api credentials in javascript client app. Keep Salesforce keys in RealComposer Vault; JavaScript / HTML uses rc_live_ tokens only.",
  "headline": "Keep Salesforce tokens off the browser",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 10,
  "clientPlatform": "JavaScript / HTML",
  "upstreamServices": [
    "Salesforce"
  ],
  "searchIntentQuery": "hide salesforce api credentials in javascript client app",
  "directAnswerSummary": "Edge pipeline attaches Bearer tokens so static sites never embed secrets. For \"hide salesforce api credentials in javascript client app\", store SALESFORCE_ACCESS_TOKEN in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} from a Worker, and let JavaScript / HTML hit only https://realcomposer.com/v1/workspace/hide-salesforce-credentials-javascript with an rc_live_ client token.",
  "problem": {
    "title": "Why JavaScript / HTML leaks Salesforce credentials",
    "explanation": "Attackers routinely extract Salesforce secrets from JavaScript / HTML builds. Direct browser calls also expose internal error payloads with hostnames.",
    "risks": [
      "Production Salesforce keys copied from JavaScript / HTML bundles",
      "Compliance violations after credential leaks",
      "Attackers replaying vault-grade scopes from a laptop"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Create SALESFORCE_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Use GET against https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache)."
    },
    {
      "stepNumber": 3,
      "title": "Call from JavaScript / HTML",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const data = await fetch('https://realcomposer.com/v1/workspace/hide-salesforce-credentials-javascript', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n}).then(r => r.json());"
    }
  ],
  "pipelineConfig": {
    "name": "Hide salesforce api credentials in javascript client app",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "salesforce",
        "upstreamUrlTemplate": "https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.SALESFORCE_ACCESS_TOKEN}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "contactId",
          "sourcePath": "Id",
          "type": "string",
          "sourceStep": "salesforce"
        },
        {
          "targetPath": "email",
          "sourcePath": "Email",
          "type": "string",
          "sourceStep": "salesforce"
        },
        {
          "targetPath": "name",
          "sourcePath": "Name",
          "type": "string",
          "sourceStep": "salesforce"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_hide-sal",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "hide-salesforce-credentials-javascript"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "contactId": "sample",
    "email": "sample",
    "name": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/hide-salesforce-credentials-javascript\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should JavaScript / HTML store instead of Salesforce secrets?",
      "answer": "Yes for hide-salesforce-credentials-javascript. Ship only an rc_live_ client token in JavaScript / HTML; RealComposer injects SALESFORCE_ACCESS_TOKEN on https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "hide-salesforce-credentials-javascript forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Upstream steps in hide-salesforce-credentials-javascript honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "hubspot-api-client-proxy",
    "reverse-proxy-api-key-protection"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/hide-salesforce-credentials-javascript",
    "markdown": "https://realcomposer.com/recipes/hide-salesforce-credentials-javascript.md",
    "json": "https://realcomposer.com/recipes/hide-salesforce-credentials-javascript.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=hide-salesforce-credentials-javascript&via=agent"
  }
}