JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q51158F
  • License ISC

React native WebSocket Secure

Package Exports

  • react-native-wss

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-wss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React native WebSocket Secure

Every project what i created has problem with securing websockets. So, I decide to share my codes with everyone, and i hope this will be merged into react native one day. This library allows you to set wss address in WebSocket with ca (plain cert), pfx (base64) and passphrase.

Installing

Install the react-native-wss repository & yauzl library to devDependencies

npm i --save-dev react-native-wss yauzl

Add postinstall into project package.json scripts object

"scripts": {
  "postinstall": "node node_modules/react-native-wss/scripts/postinstall.js"
}

Run the postinstall

npm i
# or
npm run postinstall

API

Now, you can use wss address with certificates. ( No need to import any other libs. )

this._ws = new WebSocket( 'wss://192.168.0.1', [],
{
  headers: { Authorization: 'Bearer 123' },
  ca: '-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----\n',
  pfx: 'base64==',
  passphrase: 'mustbedefinedforpfx'
});