# @onekeyfe/react-native-sni-connect

> A React Native library for SNI-based HTTP requests with DNS caching and request management

Latest version **6.7.0-8** (published 2026-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @onekeyfe/react-native-sni-connect
pnpm add @onekeyfe/react-native-sni-connect
yarn add @onekeyfe/react-native-sni-connect
bun add @onekeyfe/react-native-sni-connect
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.7.0-8 |
| Published | 2026-10-22 |
| First published | 2025-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 194.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | @onekeyhq |
| Maintainers | 1keyfe |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/@onekeyfe/react-native-sni-connect
- Repository: https://github.com/OneKeyHQ/app-modules
- Homepage: https://github.com/OneKeyHQ/app-modules/tree/main/native-modules/react-native-sni-connect#readme
- Issues: https://github.com/OneKeyHQ/app-modules/issues
- npm.io page: https://npm.io/package/@onekeyfe/react-native-sni-connect

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.7.0-8 (latest) — 2026-10-22
- 6.7.0-alpha.344 (next) — 2026-10-21
- 3.0.179-alpha.304 (pr-145) — 2026-10-15
- 6.7.0-alpha.343 — 2026-10-21
- 6.7.0-alpha.342 — 2026-10-21
- 6.7.0-alpha.341 — 2026-10-21
- 6.7.0-alpha.340 — 2026-10-20
- 6.7.0-alpha.339 — 2026-10-20
- 6.7.0-alpha.338 — 2026-10-20
- 6.7.0-alpha.337 — 2026-10-20
- 6.7.0-alpha.336 — 2026-10-20
- 6.7.0-alpha.335 — 2026-10-20
- 6.7.0-7 — 2026-10-19
- 6.7.0-6 — 2026-10-19
- 6.7.0-5 — 2026-10-19
- … 147 more at https://npm.io/package/@onekeyfe/react-native-sni-connect/versions

## README

# @onekeyfe/react-native-sni-connect

OneKey SNI HTTP client for React Native. Performs HTTPS requests to a caller-supplied
IP address while preserving the original TLS SNI / `Host` of a hostname, so certificate
chain and hostname verification are still enforced against the real hostname (not the IP).

Backed by EMASCurl (libcurl) on iOS and OkHttp on Android.

## Installation

This package is published as part of the OneKey `app-modules` workspace:

```sh
yarn add @onekeyfe/react-native-sni-connect
```

iOS: add Aliyun's spec repo and make `EMASCurl` modular in your app Podfile,
then run `pod install`:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/aliyun/aliyun-specs.git'

target 'YourApp' do
  # React Native autolinks SniConnect. This explicit pod keeps Swift
  # `import EMASCurl` visible when building static libraries.
  pod 'EMASCurl', :modular_headers => true
end
```

Android autolinks.

## Usage

```ts
import {
  request,
  cancelRequest,
  cancelAllRequests,
  clearDNSCache,
  getDebugSnapshot,
  isProxyActiveForUrl,
} from '@onekeyfe/react-native-sni-connect';

const proxyActive = await isProxyActiveForUrl('https://example.com/api/v1/ping');
if (proxyActive) {
  // Product adapters should avoid entering SNI mode when a per-URL/system proxy
  // is active. Low-level SNI requests still bypass proxies directly.
}

const res = await request({
  // requestId is optional; required only if you want to cancel the request.
  requestId: 'health-check-1',
  ip: '93.184.216.34', // must be a public IP literal (private/loopback/metadata are rejected)
  hostname: 'example.com', // used for SNI, Host header and certificate validation
  method: 'GET',
  path: '/api/v1/ping', // relative path only — absolute URLs are rejected
  headers: { 'Content-Type': 'application/json' },
  timeout: 30_000,
});

console.log(res.status, res.headers, res.data);

// Cancellation (requires requestId on the request)
await cancelRequest('health-check-1');
await cancelAllRequests();

// Drop pinned-IP connections / cached clients
await clearDNSCache();

// Diagnostics for one validated hostname/IP pair
const snapshot = await getDebugSnapshot({
  hostname: 'example.com',
  ip: '93.184.216.34',
});
```

`multiValueHeaders` preserves repeated response headers when the native transport
exposes them as raw entries. On iOS, EMASCurl 1.5.5 currently hands this module a
`HTTPURLResponse` dictionary view, so duplicate header names may already be
collapsed by the transport before this adapter can observe them. Full duplicate
header preservation on iOS requires an EMASCurl version that exposes the raw
response header list.

## Specification

The behavior of the SNI connect module is governed by a normative,
platform-agnostic standard that all implementations (iOS, Android, Node/Desktop,
shared JS adapters, and any future platform) must conform to:

**-> [OneKey SNI Connect Standard (OSCS)](https://github.com/OneKeyHQ/app-modules/blob/main/native-modules/react-native-sni-connect/SPEC.md)**

Any change to request validation, destination pinning, TLS validation, redirect
handling, cancellation, response shape, or cache behavior must be checked
against OSCS.
When an implementation and the standard disagree, the implementation is wrong.

### Security notes

- The request scheme is always `https` on port `443`; `path` cannot override scheme, host or port.
- `isProxyActiveForUrl(url)` is a preflight probe for adapters. It does not enable proxying;
  native SNI transport still bypasses system proxy configuration.
- `ip` must be an IPv4/IPv6 literal that routes to a public destination; loopback, private,
  link-local (incl. cloud metadata), CGNAT, multicast and reserved ranges are rejected.
- Header names/values containing CR/LF/control characters are rejected; the `Host` header is
  managed by the module.
- Native logs go through OneKey's native logger (with sensitive-data redaction); there is no
  JS log event channel.

## License

MIT

---
_Source: https://npm.io/package/@onekeyfe/react-native-sni-connect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
