{"_id":"@arkyutao/react-native-mqtt","_rev":"2-b169b69cca8cbda3db5333fcf4a79556","name":"@arkyutao/react-native-mqtt","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@arkyutao/react-native-mqtt","version":"0.1.0","description":"The Mqtt client for react native","main":"lib/commonjs/index","module":"lib/module/index","types":"lib/typescript/src/index.d.ts","react-native":"src/index","source":"src/index","scripts":{"example":"yarn workspace react-native-mqtt-example","test":"jest","typecheck":"tsc --noEmit","lint":"eslint \"**/*.{js,ts,tsx}\"","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","prepare":"bob build","release":"release-it"},"keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/return764/react-native-mqtt.git"},"author":{"name":"yutao","email":"yutao_return@qq.com","url":"https://github.com/return764"},"license":"MIT","bugs":{"url":"https://github.com/return764/react-native-mqtt/issues"},"homepage":"https://github.com/return764/react-native-mqtt#readme","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"devDependencies":{"@commitlint/config-conventional":"^17.0.2","@evilmartians/lefthook":"^1.5.0","@react-native/eslint-config":"^0.72.2","@release-it/conventional-changelog":"^5.0.0","@types/jest":"^28.1.2","@types/react":"~17.0.21","@types/react-native":"0.70.0","commitlint":"^17.0.2","del-cli":"^5.0.0","eslint":"^8.4.1","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","pod-install":"^0.1.0","prettier":"^2.0.5","react":"18.2.0","react-native":"0.73.2","react-native-builder-bob":"^0.20.0","release-it":"^15.0.0","turbo":"^1.10.7","typescript":"^5.0.2"},"resolutions":{"@types/react":"17.0.21"},"peerDependencies":{"react":"*","react-native":"*"},"workspaces":["example"],"packageManager":"yarn@3.6.1","engines":{"node":">= 18.0.0"},"jest":{"preset":"react-native","testPathIgnorePatterns":["mock"],"modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"commitMessage":"chore: release ${version}","tagName":"v${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"eslintConfig":{"root":true,"extends":["@react-native","prettier"],"rules":{"prettier/prettier":["error",{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false}]}},"eslintIgnore":["node_modules/","lib/"],"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]},"_id":"@arkyutao/react-native-mqtt@0.1.0","gitHead":"75bf74998d00a0359ea7b9a0ae2133c2be99551e","_nodeVersion":"20.5.0","_npmVersion":"9.8.0","dist":{"integrity":"sha512-yzy3fIZpwZl3SBzK17rcDXYMBQVsz6fJ9IAJ4DizacS5tGs+p1OIReqtPoce0WRhYxBC6/d9QL1iVTcr/HTMvQ==","shasum":"6ad6241b0ef2863086a49ab6987d69e13fa000ab","tarball":"https://registry.npmjs.org/@arkyutao/react-native-mqtt/-/react-native-mqtt-0.1.0.tgz","fileCount":114,"unpackedSize":149804,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEG1+N/37SEs/Kc/JCa1KY3AnPwTB6i+7CeRSwxhDDq+AiEApKJM6lPUN2e+4Jq0FJkS3a6p8OBi3WrXn/Bcxsdseo0="}]},"_npmUser":{"name":"arkyutao","email":"yutao_return@qq.com"},"directories":{},"maintainers":[{"name":"arkyutao","email":"yutao_return@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-mqtt_0.1.0_1704875453638_0.41732451776274626"},"_hasShrinkwrap":false},"0.1.1":{"name":"@arkyutao/react-native-mqtt","version":"0.1.1","description":"The Mqtt client for react native","main":"lib/commonjs/index","module":"lib/module/index","types":"lib/typescript/src/index.d.ts","react-native":"src/index","source":"src/index","scripts":{"example":"yarn workspace react-native-mqtt-example","test":"jest","typecheck":"tsc --noEmit","lint":"eslint \"**/*.{js,ts,tsx}\"","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","prepare":"bob build","release":"release-it"},"keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/return764/react-native-mqtt.git"},"author":{"name":"yutao","email":"yutao_return@qq.com","url":"https://github.com/return764"},"license":"MIT","bugs":{"url":"https://github.com/return764/react-native-mqtt/issues"},"homepage":"https://github.com/return764/react-native-mqtt#readme","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"devDependencies":{"@commitlint/config-conventional":"^17.0.2","@evilmartians/lefthook":"^1.5.0","@react-native/eslint-config":"^0.72.2","@release-it/conventional-changelog":"^5.0.0","@types/jest":"^28.1.2","@types/react":"~17.0.21","@types/react-native":"0.70.0","commitlint":"^17.0.2","del-cli":"^5.0.0","eslint":"^8.4.1","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","pod-install":"^0.1.0","prettier":"^2.0.5","react":"18.2.0","react-native":"0.73.2","react-native-builder-bob":"^0.20.0","release-it":"^15.0.0","turbo":"^1.10.7","typescript":"^5.0.2"},"resolutions":{"@types/react":"17.0.21"},"peerDependencies":{"react":"*","react-native":"*"},"workspaces":["example"],"packageManager":"yarn@3.6.1","engines":{"node":">= 18.0.0"},"jest":{"preset":"react-native","testPathIgnorePatterns":["mock"],"modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"commitMessage":"chore: release ${version}","tagName":"v${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"eslintConfig":{"root":true,"extends":["@react-native","prettier"],"rules":{"prettier/prettier":["error",{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false}]}},"eslintIgnore":["node_modules/","lib/"],"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]},"_id":"@arkyutao/react-native-mqtt@0.1.1","gitHead":"4a99522972ab68d1d07094aa369777b34b1cfd22","_nodeVersion":"20.5.0","_npmVersion":"9.8.0","dist":{"integrity":"sha512-/Es3aWvVajkNBuI7qBSpJLd+NiyyYh5/xc9KYCnk9HT2/pxW6Pr8LeOl3uepFIDiIQ8TwyCggZ4gHVPTVdljbQ==","shasum":"3d1f23992c237fb0ba8c6cbef4854f723f6cafcc","tarball":"https://registry.npmjs.org/@arkyutao/react-native-mqtt/-/react-native-mqtt-0.1.1.tgz","fileCount":114,"unpackedSize":149714,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGDiL/999i21Oh3dPQiuiu+dh4ulzoo2woBls0kOndhNAiBEgULhgMfTSXySFmVvsQQfBWqtogqpt7HRQ/qwWpuR8g=="}]},"_npmUser":{"name":"arkyutao","email":"yutao_return@qq.com"},"directories":{},"maintainers":[{"name":"arkyutao","email":"yutao_return@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-mqtt_0.1.1_1704897342731_0.4296149504528688"},"_hasShrinkwrap":false},"0.1.2":{"name":"@arkyutao/react-native-mqtt","version":"0.1.2","description":"The Mqtt client for react native","main":"lib/commonjs/index","module":"lib/module/index","types":"lib/typescript/src/index.d.ts","react-native":"src/index","source":"src/index","scripts":{"example":"yarn workspace react-native-mqtt-example","test":"jest","typecheck":"tsc --noEmit","lint":"eslint \"**/*.{js,ts,tsx}\"","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build lib","prepare":"bob build","release":"release-it"},"keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/return764/react-native-mqtt.git"},"author":{"name":"yutao","email":"yutao_return@qq.com","url":"https://github.com/return764"},"license":"MIT","bugs":{"url":"https://github.com/return764/react-native-mqtt/issues"},"homepage":"https://github.com/return764/react-native-mqtt#readme","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"devDependencies":{"@commitlint/config-conventional":"^17.0.2","@evilmartians/lefthook":"^1.5.0","@react-native/eslint-config":"^0.72.2","@release-it/conventional-changelog":"^5.0.0","@types/jest":"^28.1.2","@types/react":"~17.0.21","@types/react-native":"0.70.0","commitlint":"^17.0.2","del-cli":"^5.0.0","eslint":"^8.4.1","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","pod-install":"^0.1.0","prettier":"^2.0.5","react":"18.2.0","react-native":"0.73.2","react-native-builder-bob":"^0.20.0","release-it":"^15.0.0","turbo":"^1.10.7","typescript":"^5.0.2"},"resolutions":{"@types/react":"17.0.21"},"peerDependencies":{"react":"*","react-native":"*"},"workspaces":["example"],"packageManager":"yarn@3.6.1","engines":{"node":">= 18.0.0"},"jest":{"preset":"react-native","testPathIgnorePatterns":["mock"],"modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"commitMessage":"chore: release ${version}","tagName":"v${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"eslintConfig":{"root":true,"extends":["@react-native","prettier"],"rules":{"prettier/prettier":["error",{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false}]}},"eslintIgnore":["node_modules/","lib/"],"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]},"_id":"@arkyutao/react-native-mqtt@0.1.2","gitHead":"9f617435561867a4faf7e76d14f5b8fa5ed41260","_nodeVersion":"20.5.0","_npmVersion":"9.8.0","dist":{"integrity":"sha512-z/8Z6a6h/vFtQlm5M0rus8cZMVu8zs84TQbOQhiwNqpYrehY0R+b2HHAxlocQPvtFx3QHP/d6xPCSwDrmG1U5Q==","shasum":"38fc92da75f3888515b69c80cfecc603a4f9a18b","tarball":"https://registry.npmjs.org/@arkyutao/react-native-mqtt/-/react-native-mqtt-0.1.2.tgz","fileCount":114,"unpackedSize":152990,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCt3f9OmXLBj8sS4lthJPecjvo8tgGuo8ODR722PgnKgAIgMNMvS+X8H4QuN7yc75mCY8iczQD6ptz6MAAZ8xjcnC4="}]},"_npmUser":{"name":"arkyutao","email":"yutao_return@qq.com"},"directories":{},"maintainers":[{"name":"arkyutao","email":"yutao_return@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-mqtt_0.1.2_1705044388589_0.7170335611365024"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-10T08:30:53.553Z","0.1.0":"2024-01-10T08:30:53.799Z","modified":"2024-01-12T07:26:28.949Z","0.1.1":"2024-01-10T14:35:42.912Z","0.1.2":"2024-01-12T07:26:28.757Z"},"maintainers":[{"name":"arkyutao","email":"yutao_return@qq.com"}],"description":"The Mqtt client for react native","homepage":"https://github.com/return764/react-native-mqtt#readme","keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/return764/react-native-mqtt.git"},"author":{"name":"yutao","email":"yutao_return@qq.com","url":"https://github.com/return764"},"bugs":{"url":"https://github.com/return764/react-native-mqtt/issues"},"license":"MIT","readme":"\n# Enhancement of Quito\n> source repository: https://github.com/6d7a/quito\n1. upgrade react-native to 0.73\n2. upgrade CocoaMQTT to 2.1.6\n3. use MqttCocoaAsyncSocket instead of CocoaAsyncSocket\n4. fix exapmle project bug\n5. fix typescript type export error\n\n--- \n# Quito ![Logo](./docs/assets/quito_round.svg)\n\nA TCP-capable MQTT client for React Native. The module provides a Typescript API for native MQTT clients on iOS and Android.\n\n- on Android, quito relies on [Paho](https://www.eclipse.org/paho/index.php?page=clients/java/index.php)\n- on iOS, quito uses [CocoaMQTT](https://github.com/emqx/CocoaMQTT)\n\nThe module provides both promise- and callback-based methods to interact with the native clients.\n\nThis libraries owes a lot to [davesters](https://github.com/davesters)' and [SudoPlz](https://github.com/SudoPlz)' respective libraries, so thank you :100:\n\n## Installation\n\n```sh\nnpm install @arkyutao/react-native-mqtt\n```\n\nTo make an unencrypted connection to an MQTT broker, make sure a consuming android application allows cleartext traffic, either generally by setting the _android:usesCleartextTraffic_ flag in the application field of the AndroidManifest.xml, or by adding a [security configuration](https://developer.android.com/training/articles/security-config).\n\n## Usage\n\nThe module provides promise- and callback-based methods to interact with the native clients.\n\n#### Callback-based usage\n\n```typescript\nimport { MqttClient, MqttOptionsBuilder } from '@arkyutao/react-native-mqtt';\n\n// build a config using the MqttOptionsBuilder\nconst config = new MqttOptionsBuilder()\n  .uri('tcp://test.mosquitto.org:1883')\n  .clientId('quito-test-client')\n  .build();\n\nconst client = new MqttClient(config);\n\nclient.init() // call init() to create native client and set up native event listeners\n  .then(() => {\n    // Subscribing to event callbacks\n    client.on(MqttEvent.CONNECTING, () => {\n      // called when client is connecting\n    });\n    client.on(MqttEvent.CONNECTED, () => {\n      // called when client is connected\n    });\n    client.on(MqttEvent.SUBSCRIBED, (topic: string) => {\n      // called when client has subscribed to a topic\n    });\n    client.on(MqttEvent.UNSUBSCRIBED, (topic: string) => {\n      // called when client has unsubscribed from a topic\n    });\n    client.on(\n      MqttEvent.MESSAGE_RECEIVED,\n      (topic: string, payload: Uint8Array) => {\n        // called when client has received a message\n      }\n    );\n    client.on(\n      MqttEvent.MESSAGE_PUBLISHED,\n      (topic: string, payload: Uint8Array) => {\n        // called when client has sent a message\n      }\n    );\n    client.on(MqttEvent.DISCONNECTED, () => {\n      // called when client has disconnected\n    });\n    client.on(MqttEvent.CONNECTION_LOST, (error?: Error) => {\n      // called when client has unexpectedly lost its connection to the broker\n    });\n    client.on(MqttEvent.EXCEPTION, (error: Error) => {\n      // called when client encountered an error\n    });\n    client.on(MqttEvent.CLOSED, (error?: Error) => {\n      // called when client was closed\n    });\n\n    // connecting to the MQTT broker\n    client.connect();\n\n    // subscribing to a message topic\n    // both a single topic or an array of topics are supported\n    client.subscribe([\n      {\n        topic: 'first/topic',\n        qos: 2, // Quality of Service\n      },\n      {\n        topic: 'second/topic',\n        qos: 1,\n      },\n    ]);\n\n    // unsubscribing from a message topic\n    // both a single topic string or an array of topic strings are supported\n    client.unsubscribe('first/topic');\n\n    // publishing a message\n    client.publish(\n      'first/topic',\n      Buffer.from('This is a test message!'),\n      0, // Quality of service\n      false // whether the message should be retained\n    );\n\n    // checking client connection\n    client.isConnected().then((isConnected: Boolean) => {\n      // process connection state\n    });\n\n    // shutting down client\n    client.end();\n  });\n```\n\n#### Promise-based usage\n\n```typescript\nimport { MqttCliet, MqttOptionsBuilder } from 'react-native-mqtt';\n\n// build a config using the MqttOptionsBuilder\nconst config = new MqttOptionsBuilder()\n  .uri('tcp://test.mosquitto.org:1883')\n  .clientId('quito-test-client')\n  .build();\n\nconst client = new MqttClient(config);\n\nawait client.init(); // call init() to create native client and set up native event listeners\n\n// Most message callbacks are redundant\n// when using the Promise-based API\nclient.on(\n  MqttEvent.MESSAGE_RECEIVED,\n  (topic: string, payload: Uint8Array) => {\n    // called when client has received a message\n  }\n);\nclient.on(MqttEvent.CONNECTION_LOST, (error?: Error) => {\n  // called when client has unexpectedly lost its connection to the broker\n});\nclient.on(MqttEvent.EXCEPTION, (error: Error) => {\n  // called when client encountered an error\n});\n\n// connecting to the MQTT broker\ntry {\n  await client.connectAsync();\n} catch (e: any) {\n  // handle error\n}\n\n// subscribing to a message topic\n// both a single topic or an array of topics are supported\ntry {\n  await client.subscribeAsync([\n    {\n      topic: 'first/topic',\n      qos: 2, // Quality of Service\n    },\n    {\n      topic: 'second/topic',\n      qos: 1,\n    },\n  ]);\n} catch (e: any) {\n  // handle error\n}\n\n// unsubscribing from a message topic\n// both a single topic string or an array of topic strings are supported\ntry {\n  await client.unsubscribeAsync('first/topic');\n} catch (e: any) {\n  // handle error\n}\n\n// publishing a message\ntry {\n  await client.publishAsync(\n    'first/topic',\n    Buffer.from('This is a test message!'),\n    0, // Quality of service\n    false // whether the message should be retained\n  );\n} catch (e: any) {\n  // handle error\n}\n\n// checking client connection\nconst isConnected = await client.isConnected();\n\n// shutting down client\ntry {\n  await client.endAsync();\n} catch (e: any) {\n  // handle error\n}\n```\n\n### Mqtt Options\n\nUse the MqttOptionsBuilder to generate a config for the MQTT client. The following options for configuring the MQTT client are available:\n\n- `clientId`: _string_ - Identifier used in the communication with the MQTT bromker\n- `username`: _string_ - Username used to authenticate the client against the broker\n- `password`: _string_ - Password used to authenticate the client against the broker\n- `keepaliveSec`: _number_ - Maximum time interval in seconds between control packets\n- `connectTimeoutMs`: _number_ - Maximum time interval the client will wait for the network connection to the MQTT broker to be established\n- `will`: _Will_ - MQTT message that the broker will send, should the client connect ungracefully.\n    - `topic`: _string_ - Topic the will will be published to\n    - `payload`: _string_ - Message of the will Base64-encoded\n    - `qos`: _QoS_ - quality of service of the will\n    - `retain`: _boolean_ - Indicates whether the will should be retained\n- `tls`: _boolean_ - Whether the client will secure the connection to the broker using TLS. Depending on the host platform, the options vary.\n    - **On Android**: If `tls == true`, at least the broker's CA certificate `android_caBase64` is required. If the broker expects the client to present a certificate as well, the shared `android_caBase64` plus `android_certificateBase64`, `keyStoreKey`, and `keyStorePassword` options become mandatory\n    - **On iOS**: If `tls == true` and no `ios_certKeyP12Base64` is provided, broker certificates will not be validated. If `tls == true` and `ios_certKeyP12Base64` is provided, the client wil authenticate using the contained crypto.\n- `ios_certKeyP12Base64`: _String_ - Base64-encoded PKCS12 archive containing client certificate and key\n- `android_caBase64`: _String_ - Base64-encoded CA certificate (DER) used by the MQTT broker\n- `android_certificateBase64`: _String_ - Base64-encoded self-signed X509 certificate (DER) of the client\n- `android_privateKeyBase64`: _string_ - Base64-encoded RSA private key of the client\n- `keyStorePassword`: _string_ - Password used in creating the client's keystore\n- `cleanSession`: _boolean_ - When set to `true`, the broker will open a non-persistent connection, during which it will not store any subscription information or undelivered messages for the client\n- `protocol`: _Protocol_ - Identifies the protocol used in the connection to the broker\n- `protocolVersion`: _number_ - Identies the MQTT version used in the connection to the broker\n- `reconnectPeriod`: _number_ - Time interval to elapse before a client will attempt to reconnect an unexpectedly disconnected client\n- `host`: _string_ - Host name of the MQTT broker to connect to\n- `port`: _number_ - Port number of the MQTT broker to connect to\n","readmeFilename":"README.md"}