{"_id":"@anttiviljami/unleash-proxy-client","_rev":"3-eb66f68ad95c9d75dceadbeb76c7ec70","name":"@anttiviljami/unleash-proxy-client","dist-tags":{"latest":"1.3.1"},"versions":{"1.4.0":{"name":"@anttiviljami/unleash-proxy-client","version":"1.4.0","description":"A browser client that can be used together with the unleash-proxy.","main":"./build/index.js","typings":"./build/index.d.ts","scripts":{"preversion":"rm -rf build && npm run build","build":"npm run build:ts && npm run build:web","build:ts":"tsc","build:web":"rollup -c rollup.config.js","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/unleash-hosted/unleash-proxy-client-js.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/unleash-hosted/unleash-proxy-client-js/issues"},"homepage":"https://github.com/unleash-hosted/unleash-proxy-client-js#readme","devDependencies":{"@babel/runtime":"^7.14.0","@types/jest":"^27.0.1","jest":"^27.0.6","jest-fetch-mock":"^2.1.2","rollup":"^1.20.3","rollup-plugin-babel-minify":"^9.0.0","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-typescript2":"^0.24.0","rollup-plugin-uglify":"^6.0.2","ts-jest":"^27.0.5","tslint":"^5.18.0","typescript":"^3.5.3","uglify-js":"^3.6.0"},"dependencies":{"@react-native-async-storage/async-storage":"^1.15.5","tiny-emitter":"^2.1.0"},"gitHead":"d1c8659ef224c28842a0bf66d03bd0bbe7120b28","_id":"@anttiviljami/unleash-proxy-client@1.4.0","_nodeVersion":"14.15.4","_npmVersion":"7.5.4","dist":{"integrity":"sha512-uI5rtS3JFnDthJJYm1As13cAA3mn+RemY3XLsS675Iie1hJ5wuNVdGTj8w7x2N6MpjqnOxC9H+AGEGOxoMm7WQ==","shasum":"d020335da496d56a14aab5299d7185caa953eaf3","tarball":"https://registry.npmjs.org/@anttiviljami/unleash-proxy-client/-/unleash-proxy-client-1.4.0.tgz","fileCount":37,"unpackedSize":95887,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhNy+LCRA9TVsSAnZWagAA6ggQAJR2D0ueXB7yjH38M75h\nXU8KYq+cj9sJP0GXEKZFm8PYLyPEIjejpL9M586EfN5h17tYaoZCj8dCNqr7\nDBDxr5E0KoDXTODgEqgsAJpGZpKXAhCy8hOiIwmuJIx5sPt6sKgBatkHSoRk\n3g59ETsLRRr4ERXqiuHr47f2hFZBQfqBmW9sFajKpeITa91tkHTV95Xeb6YJ\nVt2Hq761yozrlGdfpAoUf7H8htWzWbSVYtnNgCTvJ6n1871nnI85as5B/mRu\nr/GBErKR9avlU+KQgQuWZIbHpXFTIud0lwJBABcAgXjIEqvnU12uneFcpz1h\nXqPEO9hw+ST5xg9mG8eaXPbG974M5Y0mLxxXhoYxmMsy7m2Ci9bGEgq/QjkG\nQoxFngK7n8ZtM+USmOceih18NBNs53tLf0Mtegoe7TeW5s9w5cBNygxUsZqN\nfvR3wXdKe3O6010iONMG54mq1XEsGgkUK2wr1LbDSgtFcFPmvTO3LBKbU9pC\nxylYfHjb/5Lfth/r0wdOYaQBU9T0iDbr7/xwJUtKs1SQnO63o4wmlfsX5UoB\nRxEyamtyQo8FLRWhIXZDitfleBTvtU22oi9hg/mQOSxBkz8YL7irPRv8WIsf\nV+W5/FUsmh5F5OowpL/uI3KdTcNRO9DEw4/sYZlpgjj6kOOGQyoeMjXbC0jR\nU17p\r\n=E3M2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDN6VrlqgGpJpmqIkjQFBK/q+4R30ss6gHQ+pgumx3cIQIhALu74gZDE7zFgHME09ot+FCrxmvf1f8lmPdbjSTw65e2"}]},"_npmUser":{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"},"directories":{},"maintainers":[{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unleash-proxy-client_1.4.0_1631006603552_0.807526229717058"},"_hasShrinkwrap":false},"1.4.1":{"name":"@anttiviljami/unleash-proxy-client","version":"1.4.1","description":"A browser client that can be used together with the unleash-proxy.","main":"./build/index.js","typings":"./build/index.d.ts","scripts":{"preversion":"rm -rf build && npm run build","build":"npm run build:ts && npm run build:web","build:ts":"tsc","build:web":"rollup -c rollup.config.js","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/unleash-hosted/unleash-proxy-client-js.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/unleash-hosted/unleash-proxy-client-js/issues"},"homepage":"https://github.com/unleash-hosted/unleash-proxy-client-js#readme","devDependencies":{"@babel/runtime":"^7.14.0","@types/jest":"^27.0.1","jest":"^27.0.6","jest-fetch-mock":"^2.1.2","rollup":"^1.20.3","rollup-plugin-babel-minify":"^9.0.0","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-typescript2":"^0.24.0","rollup-plugin-uglify":"^6.0.2","ts-jest":"^27.0.5","tslint":"^5.18.0","typescript":"^3.5.3","uglify-js":"^3.6.0"},"dependencies":{"@react-native-async-storage/async-storage":"^1.15.5","tiny-emitter":"^2.1.0"},"gitHead":"d1c8659ef224c28842a0bf66d03bd0bbe7120b28","_id":"@anttiviljami/unleash-proxy-client@1.4.1","_nodeVersion":"14.15.4","_npmVersion":"7.5.4","dist":{"integrity":"sha512-zm/7NGXH7Mflos5ogomCuvj47pj9Cy9yKE30DQgbB7ZKUJTKZy1YWLsBphEb68Fn/0tPWvfWjyB9h72ySKyM9A==","shasum":"339403c6553c192e639a9861be8527dc8049309d","tarball":"https://registry.npmjs.org/@anttiviljami/unleash-proxy-client/-/unleash-proxy-client-1.4.1.tgz","fileCount":37,"unpackedSize":95715,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhNzvhCRA9TVsSAnZWagAADe0P/24NWCZ+2BxG3AQ1bFcc\nA42yCVLDjfxcc+hvwulmR4cMj3FXM/5gcc8dWnA4HijDlcQaolDh8pLBewOF\nCY1DHAofwFLCDXSn7GLPwrUjuqt0T4sFaeP1Fd/Sl4a7hqQB5rLr/8uzXYuz\nBmQqG9QbFxSbOCxc/qQRnAPYxXSbc3JJTbPcp6PT2njlnJ+uvP7tizu5MW5B\nYo0O7DRZI4k5epHVKmSjKav8SiGqfkWMU+OjrsGBPEWR5xLVQ9oIDkP1NDlP\nZ9z47N3v4oqQqTZfADpEUwp+rhMWxwmG1X9Mh+nN8xni/p5DTtDPj0OFHKFg\n0wmCywujYhfyl5LiNxrojb2f+accmXYXbLaBNYSZGj11lP6h3Hqn30TYUaLq\nw984htt0542iu4rod5jQYTP7C+BWVcWCvYYErqvrr0D8+PJ+vW2RzcDQ9mLj\nnxpsMUMDkrIXduZKqYZ0m7nXQGDZJGL1vSDmex1vdcc3/zw2RK5ahMVvHLvn\ntE62VHhdk8B/xK8GGA/XCigadZ+4M5GqaL+5Rt+8K/KutLtdHghxphrRfE5m\ngV1dRYlKXDYuXKvRg0dQ2Zb5UFckbpFbKgKOVkWpTmUDTUprKS67JoZmIaB3\nicIiUI06Ro4qNoq9yqMPAvby9bzflVYHkma6L1mYuEOZdbZJKY+Y6uRevqL7\nggHp\r\n=UrWB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEKew1hv07mO3SgTSGef6u+engqmvPw3NZH+o0mIlaAuAiEAuua7q7Cv+oQBfRywhbqWgqC4SBeccOB7sh9q380YWpE="}]},"_npmUser":{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"},"directories":{},"maintainers":[{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unleash-proxy-client_1.4.1_1631009761060_0.8613726002662603"},"_hasShrinkwrap":false},"1.3.1":{"name":"@anttiviljami/unleash-proxy-client","version":"1.3.1","description":"A browser client that can be used together with the unleash-proxy.","main":"./build/index.js","typings":"./build/index.d.ts","scripts":{"preversion":"rm -rf build && npm run build","build":"npm run build:ts && npm run build:web","build:ts":"tsc","build:web":"rollup -c rollup.config.js","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/unleash-hosted/unleash-proxy-client-js.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/unleash-hosted/unleash-proxy-client-js/issues"},"homepage":"https://github.com/unleash-hosted/unleash-proxy-client-js#readme","devDependencies":{"@babel/runtime":"^7.14.0","@types/jest":"^27.0.1","jest":"^27.0.6","jest-fetch-mock":"^2.1.2","rollup":"^1.20.3","rollup-plugin-babel-minify":"^9.0.0","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-typescript2":"^0.24.0","rollup-plugin-uglify":"^6.0.2","ts-jest":"^27.0.5","tslint":"^5.18.0","typescript":"^3.5.3","uglify-js":"^3.6.0"},"dependencies":{"@react-native-async-storage/async-storage":"^1.15.5","tiny-emitter":"^2.1.0"},"gitHead":"b9028efde19cc64f942fe32aef1bb0850bd90e8f","_id":"@anttiviljami/unleash-proxy-client@1.3.1","_nodeVersion":"14.15.4","_npmVersion":"7.5.4","dist":{"integrity":"sha512-nELPoNRdh47CcU/EzuwAgbfq2sgsmwcTWLrFz0xfPdHzJ9sjbHWnEgkd4kLSSnTOusQRKxQPBfq/01e6c8Xvbg==","shasum":"fce7607c896edc564b703b99815f6ac74c63cda9","tarball":"https://registry.npmjs.org/@anttiviljami/unleash-proxy-client/-/unleash-proxy-client-1.3.1.tgz","fileCount":37,"unpackedSize":96098,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhN6QdCRA9TVsSAnZWagAAUHwP+gLRGMXWxGgy3KzOvHtn\nQ5INebK/FybYDIoh+dcItbZ1rXHm2+jJyslbi+z4Q3Nyl19ZelxsvAzrgDlA\nr78opiebGSwKAs4H35nIm7xAlJRV4gTr0Cym+BOx9y71BahCG2sfPZr7o/R7\nvOdUv/celZIWUqvo/pWpFXfswYXXFkl/J3fCqCPrMThJUqDSmJtHJeWz3zh2\nOkZDeij2C0yUePi95i8ViiQKWPOBfBZyxNRdG/w4mxrGPsTamjM5p2TjVOfG\nV8QYhL342vVx66Y4FQ2MUvDi72kCmOW/Sz0mFoGbMFvLVWI07O8bCeSYN0Jf\niypoKKaF5wZ4abnfdEiXguvcGRD7uCrsmIolr8tmK6qqBTq394BIC12HtiWn\n1FSDHunfnyv2ZhF51N3w970qoi1zR/5DcQ1NX/VV7MXvqMgImCtcJnMgc/vI\nPtb6H9Nyx51Pna1p5Hsm6mCSwbDUDRRhiNHP0Q9Gca0rx341+1CcKbYVoK5Y\nRPhtSPf7G9tWaFiUVfyZPv4SXAh8wXJLEQe7rh9ZSqfvcgaZrgLSb1tDGDVr\ndGsny2Fxur6rVPxHibmC5vGbDUyLcffMSuzyZx9bmHwGVXD9aMS+6eCrFLEA\nb8eB2ECje83abLEGlKCK2YWA4RrqvNXk/eVuqcFV1R8ZzSJedoTbvocLVg4i\ng079\r\n=JoJv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGuMWgt/lSGEpYb7myq2mJatnqhbd3Jx+eryhDe9SAnQIgER6rgJvF3MC/SEPlwMnhz3YWORJVscIWENECHA+QzCE="}]},"_npmUser":{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"},"directories":{},"maintainers":[{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unleash-proxy-client_1.3.1_1631036445466_0.7692893969554861"},"_hasShrinkwrap":false}},"time":{"created":"2021-09-07T09:23:23.498Z","1.4.0":"2021-09-07T09:23:23.710Z","modified":"2022-04-04T14:24:09.295Z","1.4.1":"2021-09-07T10:16:01.257Z","1.3.1":"2021-09-07T17:40:45.766Z"},"maintainers":[{"name":"anttiviljami","email":"viljami@avoinsorsa.fi"}],"description":"A browser client that can be used together with the unleash-proxy.","homepage":"https://github.com/unleash-hosted/unleash-proxy-client-js#readme","repository":{"type":"git","url":"git+https://github.com/unleash-hosted/unleash-proxy-client-js.git"},"bugs":{"url":"https://github.com/unleash-hosted/unleash-proxy-client-js/issues"},"license":"ISC","readme":"# Unleash Proxy Client for the browser (js)\n\nThis is a tiny Unleash Client SDK you can use together with the \n[Unleash Proxy](https://docs.getunleash.io/sdks/unleash-proxy). \nThis makes it super simple to use Unleash from any single page app. \n\nThis client expect `fetch` to be available. If you need to support older\nbrowsers you should probably use the [fetch polyfill](https://github.com/github/fetch). \n\n## Frameworks supported\n\nThis package is not tied to any framework, but can be used together most popular frameworks, examples:\n\n- No framework\n- [React](https://reactjs.org/) - [example](https://github.com/unleash-hosted/unleash-proxy-client-js/tree/master/examples/react-app)\n- [React Native](https://reactnative.dev/) \n- [Angular JS](https://angularjs.org/)\n- [Vue.js](https://vuejs.org/)\n- ...and probably your favorite! \n\n## How to use the client as a module.\n\n\n**Step 1: Install**\n```js\nnpm install unleash-proxy-client --save\n```\n\n**Step 2: Initialize the SDK**\nYou need to have a Unleash-hosted instance, and the proxy need to be enabled. In addition you will need a proxy-specific `clientKey` in order to connect  to the Unleash-hosted Proxy.\n```js\nimport { UnleashClient } from 'unleash-proxy-client';\n\nconst unleash = new UnleashClient({\n    url: 'https://eu.unleash-hosted.com/hosted/proxy',\n    clientKey: 'your-proxy-key',\n    appName: 'my-webapp'\n});\n\n// Used to set the context fields, shared with the Unleash Proxy\nunleash.updateContext({userId: '1233'});\n\n// Start the background polling\nunleash.start();\n```\n\n**Step 3: Check if feature toggle is enabled**\n```js\nunleash.isEnabled('proxy.demo');\n```\n\n\n**Step 4: Get toggle variant**\n```js\nconst variant = unleash.getVariant('proxy.demo');\nif(variant.name === 'blue') {\n // something with variant blue...\n}\n```\n\n**Listen for updates via the EventEmitter**\nThe client is also an event emitter. This means that your code can subscribe to updates from the client. \nThis is a neat way to update a single page app when toggle state updates. \n\n```js\nunleash.on('update', () => {\n    const myToggle = unleash.isEnabled('proxy.demo');\n    //do something useful\n});\n```\n\n### SessionId - Important note!\n\nYou may provide a custom session id via the \"context\". If you do not provide a sessionId this SDK will create a random session id, which will also be stored in the provided storage (local storage). By always having a consistent sessionId available ensures that even \"anonymous\" users will get a consistent experience when feature toggles is evaluated, in combination with a gradual (percentage based) rollout. \n\n### Custom store\n\nThis SDK will use [@react-native-async-storage/async-storage](https://react-native-async-storage.github.io/async-storage/) to backup feature toggles locally. This is useful for bootstrapping the SDK the next time the user comes back to your application. \n\nYou can provide your own storage implementation. \n\nExample: \n\n```js\n\nimport SharedPreferences from 'react-native-shared-preferences';\nimport { UnleashClient } from 'unleash-proxy-client';\n\nconst unleash = new UnleashClient({\n    url: 'https://eu.unleash-hosted.com/hosted/proxy',\n    clientKey: 'your-proxy-key',\n    appName: 'my-webapp',\n\tstorage: {\n\t\tsave: (name: string, data: any) => SharedPreferences.setItem(name, data),\n\t\tget: (name: string) => SharedPreferences.getItem(name, (val) => val)\n\t},\n});\n```\n\n\n## How to use the client via CDN.\n\n```html\n<html>\n<head>\n    <script src=\"https://unpkg.com/unleash-proxy-client@latest/build/main.min.js\" type=\"text/javascript\"></script>\n    <script type=\"text/javascript\">\n        var config = {url: 'https://app.unleash-hosted.com/demo/proxy', clientKey: 'proxy-123', appName: 'web'};\n        var client = new unleash.UnleashClient(config);\n        client.updateContext({userId: '1233'})\n\n        client.on('update', () => {\n            console.log(client.isEnabled('proxy.demo'));\n        });\n        client.start();\n    </script>\n</head>\n</html>\n```\n","readmeFilename":"README.md"}