cometchat-react-native-production
Ship a CometChat React Native app safely — server-minted auth tokens instead of the Auth Key, what actually stays secret in a mobile bundle, release-build checks, and logout hygiene. Triggers: CometChat production React Native, auth token instead of auth key RN, secure CometChat RN, release build chat, is my auth key safe in the app.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- cometchat-react-native-production
- license
- MIT
- metadata
- { "tags": "chat cometchat react-native production security auth-token release", "author": "CometChat", "version": "1.0.0" }
- description
- Ship a CometChat React Native app safely — server-minted auth tokens instead of the Auth Key, what actually stays secret in a mobile bundle, release-build checks, and logout hygiene. Triggers: CometChat production React Native, auth token instead of auth key RN, secure CometChat RN, release build chat, is my auth key safe in the app.
- compatibility
- React Native >=0.77; @cometchat/chat-uikit-react-native ^5.4.0; @cometchat/chat-sdk-react-native ^4.0.28
03 SKILL.md 正文
Ground truth:
@cometchat/chat-uikit-react-native@5+catalogs/rn-sdk-v4.json. Docs:/ui-kit/react-native/react-native-cli-integration·/sdk/react-native/authentication-overview.
Companion skills (read first)
cometchat-react-native-core— install, provider chain, init→login→render. Assumed, not repeated here.cometchat-security— the enterprise auth model this client-side hardening plugs into: wiring your IdP / SSO into the token flow (your IdP → your server → mint the CometChat auth token; CometChat is not an IdP), token expiry/refresh + re-login, RBAC roles + group (SBAC) scopes, and Auth Key vs auth token vs REST API Key. Load it for a security review or any SSO question.
Use this skill when
- "is this safe to ship" · "swap the auth key for a token" · "prepare the release build"
Prerequisites & install
None beyond core, plus a backend endpoint you control for minting tokens.
The one rule: the Auth Key never ships
login({ uid }) uses the Auth Key, which can create and impersonate any user in your app. Fine on
your laptop; unacceptable in a shipped binary.
Nothing in a mobile app is secret
This is the part web developers get wrong. A React Native bundle is not a server. .env files,
react-native-config, Constants.expoConfig, obfuscation, ProGuard — all of them end up readable in
the shipped app. Anyone can unzip an IPA or APK.
"Hide the Auth Key in an env var" is not a mitigation. Remove it.
Production shape
import { CometChatUIKit } from "@cometchat/chat-uikit-react-native";
// your backend authenticates the user, then mints a short-lived CometChat
// auth token for that UID and returns it
const authToken: string = await fetchAuthTokenFromYourBackend();
await CometChatUIKit.login({ authToken });
The client never sees the Auth Key. The token is per-user, short-lived and revocable.
UIKitSettings.authKey is only needed for the login({ uid }) path — a production build should not
carry it at all.
User creation belongs on the server
CometChat.createUser needs the Auth Key, so it is a backend call made when your own signup
completes. A client that can create users can create any user.
Logout hygiene
CometChatUIKit.logout() on sign-out, and unregister the push token first (see the push skill)
— otherwise the device keeps receiving the previous user's notifications. On a shared device that is
a privacy incident, not a bug.
Before you ship
- Test a release build, not just debug. Some failures appear only there — most notably the
react-native-gesture-handlerimport-ordering crash (bare-patterns). - Build, then grep the output bundle for the Auth Key. It must not be present.
- Verify calls and push on real devices — neither is provable on a simulator.
- Check both platforms; Android and iOS diverge in native config, permissions and build failures.
Common pitfalls
- Shipping the Auth Key — env vars and obfuscation do not hide it.
- Creating users client-side — needs the Auth Key; move it to the backend.
- Not unregistering push on logout — the next user receives the previous user's messages.
- Signing off from a debug build — release-only failures exist.
- Testing one platform only — the native layer differs.
Verify it works
- Every emitted symbol is in
catalogs/rn-sdk-v4.json/rn-v5.json. npm run verify:fences:rn-v5is green.- Grep a release bundle for the Auth Key — absent.
- Sign out, then confirm the device stops receiving that user's notifications.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.