# Firebase user profile api strip sensitive fields

> Remove refresh tokens providerData internals at edge. For "firebase user profile api strip sensitive fields", store FIREBASE_ACCESS_TOKEN in Secret Vault, call https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}} from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/strip-firebase-user-profile-sensitive with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/strip-firebase-user-profile-sensitive
- Client platform: React Native
- Upstream services: Firebase
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/strip-firebase-user-profile-sensitive.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=strip-firebase-user-profile-sensitive&via=agent

## Problem: Firebase JSON bloat on React Native

Oversized Firebase payloads inflate parse time and mobile data charges for React Native users.

- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys

## Solution steps

1. **Store upstream credentials in Secret Vault**: Create FIREBASE_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}, and Map only the UI fields in output mapping so clients never download audit or nested blobs.

3. **Call from React Native**: Allowed origins on the token should list every React Native host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/strip-firebase-user-profile-sensitive', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Firebase user profile api strip sensitive fields",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "firebase",
      "upstreamUrlTemplate": "https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.FIREBASE_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "docName",
        "sourcePath": "name",
        "type": "string",
        "sourceStep": "firebase"
      },
      {
        "targetPath": "fields",
        "sourcePath": "fields",
        "type": "object",
        "sourceStep": "firebase"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/strip-firebase-user-profile-sensitive" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_strip-fi",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "strip-firebase-user-profile-sensitive"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "docName": "sample",
  "fields": "sample"
}
```

## FAQ

### Can React Native call Firebase without holding the production key?

Point React Native at /recipes/strip-firebase-user-profile-sensitive edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Does POST traffic get cached?

strip-firebase-user-profile-sensitive keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.

### Can I restrict which domains call this pipeline?

Upstream steps in strip-firebase-user-profile-sensitive honor timeoutMs and optional fallback JSON without leaking secrets.
