{"_id":"@een/two-way-audio-web-sdk","_rev":"5-77c9a23bc0239cba134e134a17ff90ad","time":{"created":"2023-03-03T06:56:48.323Z","1.0.0":"2023-03-02T09:04:20.492Z","modified":"2023-03-08T06:25:51.251Z","1.0.1":"2023-03-03T06:56:48.567Z","1.0.2":"2023-03-03T07:34:09.471Z","1.0.3":"2023-03-08T06:25:51.133Z"},"name":"@een/two-way-audio-web-sdk","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.1":{"name":"@een/two-way-audio-web-sdk","version":"1.0.1","description":"EEN Two-way Audio Web SDK","main":"index.js","type":"module","author":{"name":"een","url":"Eagle Eye Networks"},"license":"Unlicensed","dependencies":{"child_process":"^1.0.2","eventemitter3":"^4.0.7","npm":"^8.13.2","run":"^1.4.0","webrtc-adapter":"^8.1.2"},"gitHead":"fd78578f29054239bba16d05defbf18105c07046","_id":"@een/two-way-audio-web-sdk@1.0.1","_nodeVersion":"16.17.0","_npmVersion":"9.4.0","dist":{"integrity":"sha512-9UAIZ0R4+7i/8SvOWPRPYNX1ByRQfgKOkeSExdh/i363Ft7DWiItAXPf5vZzGBi4HraVFyGQ7voDFjlgPvsF2A==","shasum":"85ae7ed028ce01b766fa6deba79d7a4ab6aced06","tarball":"https://registry.npmjs.org/@een/two-way-audio-web-sdk/-/two-way-audio-web-sdk-1.0.1.tgz","fileCount":3,"unpackedSize":72877,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCh7RTRUZg0MXSskpOtX8cdyQduEMBnkrYYn5pQ6puYzQIgFA+hbtFKOHaVh0BqhE3T2CAy7No0l/VOV7IRDbvIZ0M="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAZowACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqdTg/7B34RvXQOl/42oCFH1mT7QDNAg9uQHZaA1o7sVka22+u1eRPL\r\n+rIqIF5+rIJ6aqO8f2EX+Pl80RMVZtNjxvWly95nOQPshy/9Ukxz2AynuwAy\r\nTVKhjV4d+B9tBcafdp/pdwAv83Wrkcnm5GUG3m6QB4tqFUn2ZVPr3fHYC5zZ\r\nsMdA+XttDjZPgPehM6vuUK0OsYaRXt7fLuFwsStdLVp88xny2mdCg+NcZBgK\r\nZb96gaXJ8UzVaTAPnx8zafid3SQIRAPrKbVovUaYSHgS+OsiIOejCE7RyoKh\r\nrCMqh0sckc/ho4j+1vX4AfeWkhMYIyFn06z0MW+KsDkoH8jSIXpGzZEFQG0m\r\n1zrmLekmENEVt4EKQAbJ140fr47mBcto7sIUomhixxr/c3FEc/vpGtO+3VEv\r\n+12pmfRb3VJZmalhN8CS00mFRvoKOXqG4RJJqxy3GdrbHF1p4kj0YOE/9VpH\r\ngNhzybK4wc69937awaqp38ZAhvDuw2+pB5P/6h0z6bX1I2LJ67GMkxfgrv+S\r\nV+GXEyNDWmtB/sNXvCLsC9z1uWbsCm3d36/6sPmRCIj09NiT6AX9qtFC0dG5\r\nFQBwqSkR3SHEindyhGgFRFNbpgbjQAf+eyI5TOWLa0dDZv5rW8+aTO77uBky\r\nW4MjekyBQWf+4FcvNx5uX9FTvhddHaQ3JL8=\r\n=1oY6\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"kira-een","email":"knebilak@een.com"},"directories":{},"maintainers":[{"name":"kira-een","email":"knebilak@een.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/two-way-audio-web-sdk_1.0.1_1677826608415_0.4898662594800063"},"_hasShrinkwrap":false},"1.0.2":{"name":"@een/two-way-audio-web-sdk","version":"1.0.2","description":"EEN Two-way Audio Web SDK","main":"index.js","type":"module","author":{"name":"een","url":"Eagle Eye Networks"},"license":"Unlicensed","dependencies":{"child_process":"^1.0.2","eventemitter3":"^4.0.7","npm":"^8.13.2","run":"^1.4.0","webrtc-adapter":"^8.1.2"},"gitHead":"f77cea44e46a5b94ee41cbc95d03c64dea7fa60c","_id":"@een/two-way-audio-web-sdk@1.0.2","_nodeVersion":"16.17.0","_npmVersion":"9.4.0","dist":{"integrity":"sha512-y496OhXTHDslFVHIA7KkiC/QYiPUgVYUdrIz66yVGeNrf+TtCkegfoM561t2georc8FRDwFcL5hhmjRGWf7giQ==","shasum":"44118199b57facac7a3096a3cd23fcbde0b6a258","tarball":"https://registry.npmjs.org/@een/two-way-audio-web-sdk/-/two-way-audio-web-sdk-1.0.2.tgz","fileCount":3,"unpackedSize":72620,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIjJC2QuzEkg42GWM9KgTqixho4rAeb0c9CQ1KIbfihgIhAIQZywrFMaWT5Hx3ILGm73VaVJOtu3VOojZqYFy7JW3q"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkAaLxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrsVA/9E9pIQZzJRDq5I0DnvbAGg1AVe8LeXspY6QHu4K3eknu/Ow52\r\ntQqUPZYW/11FlELXuL3JymG+1IrBxgaAKfcsicGFd/BCeC/jOdPtbDjln7/Q\r\nwgeEz4iW/rR98Ybe1jUg4ITHkWLW1n+0mJfK4FVV/toOkoT6EPER5CTqm5sw\r\nv/muggQ9viiUiuoefEWYRE99Bq21NMBixVKZyd6bNj+BATq9BRHDqSf0qgCW\r\nTuevScApul2n+XG1nA9+4afPaZGOHTcyijYNCYZb2rpgWo0wrxk0QKZAomF1\r\nfi7/ecb1jk2ouh5FzKjfGhUnWHq80kp03rLPy8O4NQKY9fB8goprif64DgZH\r\nrzGDHy/9osqLQqzKG/XR6I1bkT6JBS9D+gMPozWN+JhQzSFSGn6gNk86oXO/\r\noSqbmZzDK1PZbZQ8JvAMra9TGtXsT03KXiYej4QPojsxkY3iWuRuqydnWwrI\r\nVEv8zXcJ1zv0fRoPc1n7/AEeWPcpKVrUzMqzJRuXymid+R0fC5Sd7ss2Fy9K\r\nCn4iCbwhiXy8U8XWrjjiJMIlf3noR2FfMJHEHD4ILwnQhgy+ABAx7+t6FE0H\r\nveVmMVWAH/BIN8oPymN45LbLkyghsA8MybUn0DkFLJG8jaSwWeATy36BD81U\r\n3aASgt2Wq7N+Hpmw/8LWgFwtnFpzmKIPtac=\r\n=9qyy\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"kira-een","email":"knebilak@een.com"},"directories":{},"maintainers":[{"name":"kira-een","email":"knebilak@een.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/two-way-audio-web-sdk_1.0.2_1677828849328_0.63835760404921"},"_hasShrinkwrap":false},"1.0.3":{"name":"@een/two-way-audio-web-sdk","version":"1.0.3","description":"EEN Two-way Audio Web SDK","main":"index.js","type":"module","author":{"name":"een","url":"Eagle Eye Networks"},"license":"Unlicensed","dependencies":{"child_process":"^1.0.2","eventemitter3":"^4.0.7","npm":"^8.13.2","run":"^1.4.0","webrtc-adapter":"^8.1.2"},"gitHead":"f907eba776b1d97e9b5dc1ae62f99081051aadd3","_id":"@een/two-way-audio-web-sdk@1.0.3","_nodeVersion":"16.17.0","_npmVersion":"9.4.0","dist":{"integrity":"sha512-ptT8eLhBgF7ZQkgeNoPrpVM0qb5s4lUzuX/HKqtb1KIi6S/CF3ZgSexMGxLdnZXlD46Ns8yuJrTZT86znWBGRg==","shasum":"d2cecbb0500ef40048e5e39dc0084f99795265d6","tarball":"https://registry.npmjs.org/@een/two-way-audio-web-sdk/-/two-way-audio-web-sdk-1.0.3.tgz","fileCount":3,"unpackedSize":72784,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCf7xY4YKlqBnChFSXgIrw4at7nBd8xnyAInGGqVGNI3gIhAKbYTMAA0sSXqo5ndYUVY3mD9GEjtCB1xS/Fd5rMyycq"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCCpvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpfvQ/+JSjwvtmZKCF+xjX3+6hZlAPuj//TDaDTqaYxMOVou1aLoGYT\r\n5UAyESkKJkOXKtfBCuLWF2+quSHjtkaAbKcA+RsI+DTqkLc17pyipdFpt4bW\r\nYTLSU7AEYWH2NRUw/In4q2a4TDl50uTs1K4jZhmQGxpU17o6W4VvcoilsD6K\r\nwZF1FgYh8gLFTTWanmp8ygXsArzqCuWkFC1Biv90pALyllHpTJ/dn+Lqkv+X\r\nyadMjAzjPWd5iNMtvgvV+Zm+V984zT7HnyDATLf7eGGvzfJ7GbGwwgkD9gpu\r\nQT3GiZ+l1+jT4iJ6EjgJEaZlAyv7R+RWJivMJfu1coYkqMFDLj3JI27wpGV9\r\nQJs1oQeCkNEg1V4aQcCZdawGc2oPhOK4X4JSuECFYN67smhtyRIXZ05APY0x\r\nN00neZcbQRhWhN1+R4tyLeIpKJKG/bzPBV9UtD3Q1YLPd0x2O/zvjE1hnI2r\r\nzpwp5egag3IEgJZYwLIKBEEB8zCjKxbPDwOVTLBiI4cQJbM36iFbnn6nN9rz\r\nhpk4Fr37oGp1oqPfvSh4nu05TdnNrsHkRdcWdvYPFmZYHXFnteQIRbx9bidt\r\n4vGUo/7AdXXClKorwWesAS2O7Gj01Sar6bsHpJqUOWKaCSq62tBW0/+twg2M\r\n3zcPJO6GaXwCrCOBdpTwnI0QArcm5P/Twuk=\r\n=LqM4\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"kira-een","email":"knebilak@een.com"},"directories":{},"maintainers":[{"name":"kira-een","email":"knebilak@een.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/two-way-audio-web-sdk_1.0.3_1678256751008_0.31584097580052006"},"_hasShrinkwrap":false}},"maintainers":[{"name":"kira-een","email":"knebilak@een.com"}],"description":"EEN Two-way Audio Web SDK","author":{"name":"een","url":"Eagle Eye Networks"},"license":"Unlicensed","readme":"## EEN Two-way Audio Web SDK\nCopyright (C) 2023 Eagle Eye Network B.V. - sales@een.com This software can not be copied and/or distributed without \nthe express permission of Eagle Eye Networks.\n\nThe EEN Two-way Audio Web SDK is a wrapper for the communication between a **client** (ie. Web Browser) and the\nEEN Two-way Audio **Signaling Services** using WebRTC. Developers can use the [exposed methods](#methods) to easily \nestablish and disconnect sessions.\n\n## Quick start\n\n### Installation\n\nYou can use following command to install @een/two-way-audio-web-sdk:\n\n```\nnpm i @een/two-way-audio-web-sdk\n```\n\nIf successful, the **@een/two-way-audio-web-sdk** should appear in the project's dependencies in `package.json`.\n\n### Preparation\n\nTo establish a Two-way Audio session by using the SDK, you need to prepare the following variables:\n\n1. `<audio />`: an Audio HTML element, which will be the displaying media for\n   talkdown.[HTML/DOM element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio)\n2. `talkdown_feed`: a JavaScript object which contains the necessary variables for establishing talkdown\n   connection. [More info](#feed_object)\n\n### Declaration\n\nSince EEN Two-way Audio Web SDK is built in UMD format, you have to import it based on the framework which you are\nusing. For example, if you are using Vue, you should import it in the `main.js` as below:\n\n```Javascript\nimport {createApp} from 'vue'\nimport App from './App.vue'\nimport EENWebRTC from '@een/two-way-audio-web-sdk';\n\nconst app = createApp(App)\napp.use(EENWebRTC);\napp.mount('#app')\n```\n\nOnce you finished import, you can declare the instance as following:\n\n```JavaScript\nconst audioElement = document.getElementById(\"two-way-audio\");\n\n// Instantiate a new Two-way Audio client with settings\nconst client = new EENWebRTC({audioDom: audioElement});\n```\n\nYou have to pass the `audioDom`(HTML/DOM audio element) when creating the client.\n\n### Register status callbacks\n\nThe EENWebRTC extends from [EventEmitter3](https://github.com/primus/eventemitter3), all connection status are exposed\nby [emitter.emit()](https://nodejs.org/api/events.html#emitteremiteventname-args) function. The status are like below:\n\n| Status Name | Description | Param |\n| -- | -- | -- |\n| connecting | Once the end user makes a call, the client will be in this status, and it will last until connection is\nestablished. | None |\n| connected | Once the connection is established, the client will be in this status. | None |\n| disconnected | Any connection error happens or the end user closes the call, the client will be in this status until\nthe user makes the next call. [More details](#errors). | `reason`: the reason of why disconnected: `USER`\nor `ERROR`, `error`(optional): It will be `null` if the user disconnects talkdown. Otherwise, it is a\nstandard [Javascript Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)\nobject. |\n\nEnd-user can register the status callback to listen the client status. For example:\n\n```JavaScript\nclient.on('connecting', function () {\n    // Update UI icon to be connecting stage.\n    this.updateSpeakerIcon('connecting');\n});\n\nclient.on('connected', function () {\n    // Update UI icon to be connected stage.\n    this.updateSpeakerIcon('connected');\n});\n\nclient.on('disconnected', function (reason, error) {\n    // Update UI icon to be disconnected stage.\n    this.updateSpeakerIcon('disconnected');\n\n    if (error) {\n        // Handle the error.\n        console.error('WebRTCError reason: ', reason);\n        console.error(error);\n    }\n\n    if (reason !== 'USER') {\n        // If error type is not USER, then it means connection error happens, so here you can popup some notification view.\n        if (error.message === 'Speaker is busy') {\n            this.speakerMessageNotification('device is busy');\n        } else {\n            this.speakerMessageNotification('disconnect error');\n        }\n    } else {\n        // If error type is USER, it means disconnection is caused by end user. So here you can popup some dissconnected message on the page.\n        this.speakerMessageNotification('disconnected');\n    }\n});\n```\n\nIf a disconnect happens, the EENWebRTC client will close the websocket connection by itself.\n\n### `connect()`: Start A Two-way Audio Session\n\nUse the `connect(feed)` method to start a Two-way Audio session.\n\n```Javascript\n// Note: feed object is provided by the /feeds API.\n// This is just an example.\nlet feed = {\n    \"sourceId\": \"100abcde\",\n    \"webRtcUrl\": \"wss://edge.c000.eagleeyenetworks.com\",\n    \"type\": \"talkdown\",\n    \"id\": \"100abcde-talkdown\",\n    \"mediaType\": \"halfDuplex\"\n}\n\nclient.connect(feed);\n```\n\n### `close()`: Disconnect\n\n```Javascript\n// Disconnect the call\nclient.close();\n```\n\n## The Authorization\n\nThe WebRTC SDK requires EEN authentication and `access_token`. Please refer\nto https://developerv3.eagleeyenetworks.com/docs/login-public-client .\n\n## <a id=\"feed_object\"></a>The feed object\n\nYou can get the `feed` object from API V3 / feeds.\nThe `feed` object must have: `deviceId`, `webRtcUrl`, `type`, and `mediaType`.\n\n| Variable name | Type | Description | Example |\n| :-- | :--: | :-- | :-- |\n| sourceId | String | The ESN of doing talkdown device(Camera/Speaker). | “100abcde“ |\n| webRtcUrl | String | The websocket URL of edge service. The url is composed according to\nthe `wss://edge.<speaker_account_cluster>.eagleeyenetworks.com` pattern. | “wss: //edge.c000.eagleeyenetworks.com“ |\n| type | String | The service type of web RTC, here the value is always `talkdown`. | “talkdown“ |\n| mediaType | String | The media type string of talkdown, here only support `fullDuplex` and `halfDuplex` |\n“halfDuplex” |\n\n## <a id=\"errors\"></a>Errors\n\nThe EENWebRTC client can catch all errors and throws `Error` by the `disconnected` status callback,\nlike `webRTCClient.emit(Events.DISCONNECTED, Reasons, Error);`. There are two `Reasons`:\n\n- `USER`: If the user disconnects the call, then the client will throw this reason with error `null` to the callback.\n- `ERROR`: Any connection errors, including websocket error, signal connection error, auth error etc., will use this\n  reason.\n\nThe ClientError’s cause could be one of following:\n\n- `busy`\n- `invalidRequest`\n- `clientMediaError`\n- `serviceUnavailable`\n- `authorizationFailed`\n- `permissionDenied`\n- `resourceNotFound`\n- `invalidParameters`\n- `alreadyConnected`\n\nThere are several ERRORs as below:\n\n- `ClientError(message: 'The audioElement can not be null', cause: 'invalidParameters')`: When a user does not pass any\n  audioElement to EENWebRTC constructor method, this error will show.\n- `ClientError(message: 'The webRtcUrl can not be null', cause: 'invalidParameters')`: When a user passes a null value\n  or no value of webRtcUrl to EENWebRTC constructor method, this error will show.\n- `ClientError(message: 'The deviceId can not be null', cause: 'invalidParameters')`: When a user passes a null value or\n  no value of deviceId to EENWebRTC constructor method, this error will show.\n- `ClientError(message: 'Already connected', cause: 'alreadyConnected')`: If the EENWebRTC client has established one\n  talkdown connection, the following connection will be rejected and get this error.\n- `ClientError(message: 'Connection to Signaling Services lost', cause: 'serviceUnavailable')`: If signal disconnects by\n  any connection error, the end user will get this error.\n- `ClientError(message: 'One or more transports has terminated in an error', cause: 'serviceUnavailable')`: If\n  PeerRTCConnection's connectionState failed, the client will throw this error to the end user.\n- `ClientError: (message: 'Failed to get stream', cause: 'clientMediaError')`: If client can't get audio stream from\n  peer connection, end user will get this error.\n- `ClientError: (message: 'Connection closed during initialization', cause: 'serviceUnavailable')`: If websocket is\n  closed during establishing a talkdown connection, the end user will see this error.\n- `Your token not valide`: This error is from the signal server when token doesn't pass authorization in the signal\n  server.\n- `Device is busy`:  This error is from the signal server. If the device is in another talkdown session, the user will\n  get this error when trying to establish the talkdown connection.\n- WebSocket errors.\n\n## <a id=\"methods\"></a>Methods of client\n\nThe `client` object only has below methods:\n\n- `connect(talkdown_feed: object)`: establish the Two-way Audio connection.\n- `getStatus()`: get current WebRTC client connection status.\n- `close()`: disconnect the Two-way Audio.","readmeFilename":"README.md"}