{"_id":"@dhealthtools/desktop-wallet-plugin-update","name":"@dhealthtools/desktop-wallet-plugin-update","dist-tags":{"latest":"1.1.3"},"versions":{"1.1.3":{"name":"@dhealthtools/desktop-wallet-plugin-update","description":"dHealth Network - Update connector","homepage":"https://github.com/dhealthproject/plugin-health-to-earn-strava#readme","version":"1.1.3","author":{"name":"dHealth Network","email":"info@dhealth.foundation","url":"https://dhealth.network"},"repository":{"type":"git","url":"git+https://github.com/dhealthproject/plugin-health-to-earn-strava.git"},"license":"LGPL-3.0-only","main":"dist/dHealthWalletPluginUpdate.umd.min.js","types":"dist/types/Strava.d.ts","browser":{"./sfc":"dist/views/pages/HealthToEarn/HealthToEarn.vue"},"scripts":{"serve":"npm run serve --prefix firebase-app/functions","build":"npm run build:lib && npm run build:ts && npm run copy:vue","build:lib":"vue-cli-service build --target lib --name dHealthWalletPluginUpdate src/Strava.ts --mode production --formats umd-min","build:ts":"tsc --emitDeclarationOnly","copy:vue":"cpy '**/*.vue' '../dist/' --cwd=src --parents"},"dependencies":{"@dhealth/sdk":"^1.0.3-alpha-202110081200","@dhealth/wallet-api-bridge":"^1.3.0","@dhealth/wallet-components":"^1.3.0","axios":"^0.24.0","bignumber.js":"^9.0.1","moment":"^2.29.1"},"devDependencies":{"@babel/compat-data":"^7.14.0","@babel/core":"^7.14.2","@vue/cli-plugin-babel":"^4.5.13","@vue/cli-plugin-typescript":"^4.5.13","@vue/cli-plugin-unit-jest":"^4.5.13","@vue/cli-service":"^4.5.13","@vue/eslint-config-typescript":"^5.0.1","@vue/test-utils":"^1.2.0","babel-core":"7.0.0-bridge.0","babel-helper-vue-jsx-merge-props":"^2.0.3","babel-plugin-syntax-jsx":"^6.18.0","babel-plugin-transform-runtime":"^6.22.0","babel-plugin-transform-vue-jsx":"^3.5.0","babel-preset-env":"^1.7.0","babel-preset-stage-2":"^6.24.1","rimraf":"^3.0.2","semver":"^5.3.0","typescript":"^3.9.9","vue-template-compiler":"^2.5.2","cpy-cli":"^3.1.1","less":"^3.0.4","less-loader":"^4.1.0","vue":"^2.6.10","vue-property-decorator":"^8.1.0"},"gitHead":"d859284dfb89d2605319a4d356e399e4f694bbec","bugs":{"url":"https://github.com/dhealthproject/plugin-health-to-earn-strava/issues"},"_id":"@dhealthtools/desktop-wallet-plugin-update@1.1.3","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-f9j9XHbwH5w/6n2WA9OXfjm3ez7AlDlO3OYGy0YEm1NaTxaIYsvYDb48R74q13K8fYxN/tty2/xr5AUIB8cufw==","shasum":"79462fc8dee160d135b76e8f7e208bf2cab294bb","tarball":"https://registry.npmjs.org/@dhealthtools/desktop-wallet-plugin-update/-/desktop-wallet-plugin-update-1.1.3.tgz","fileCount":12,"unpackedSize":22640407,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDehHEbbfv2Sq5xyEz5UwBS9hbcxh6onR7FVsZZ23NFgIgQMZD3AVAyQ91ztLo800eMe+M/x9JehoDAqj+KHcei/Y="}]},"_npmUser":{"name":"nanhson","email":"n.anhson89@gmail.com"},"directories":{},"maintainers":[{"name":"nanhson","email":"n.anhson89@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/desktop-wallet-plugin-update_1.1.3_1691664430843_0.9726814046702614"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-10T10:47:10.738Z","1.1.3":"2023-08-10T10:47:11.079Z","modified":"2023-08-10T10:47:11.458Z"},"maintainers":[{"name":"nanhson","email":"n.anhson89@gmail.com"}],"description":"dHealth Network - Update connector","homepage":"https://github.com/dhealthproject/plugin-health-to-earn-strava#readme","repository":{"type":"git","url":"git+https://github.com/dhealthproject/plugin-health-to-earn-strava.git"},"author":{"name":"dHealth Network","email":"info@dhealth.foundation","url":"https://dhealth.network"},"bugs":{"url":"https://github.com/dhealthproject/plugin-health-to-earn-strava/issues"},"license":"LGPL-3.0-only","readme":"<p align=\"center\"><img src=\"https://dhealth.network/wp-content/uploads/2021/01/dHealth-Network-Logo-color-change.png\" width=\"400px\"></p>\n\n# dHealth Wallet Plugin: Health to Earn powered by Strava\n\n[![npm-badge][npm-badge]][npm-url]\n[![dl-badge][dl-badge]][npm-url]\n[![License](https://img.shields.io/badge/License-LGPL%203.0%20only-blue.svg)](https://opensource.org/licenses/LGPL-3.0)\n\n[Health to Earn][self-url] powered by Strava is a showcase to earn `dhealth.dhp` on [dHealth Network][parent-url].\n\nVisit the showcase website for more information [here][showcase-url].\n\n- [Components found here](#components-found-here)\n- [Environment](#environment)\n- [Development](#development)\n- [Licensing](#license)\n\n## Sequence diagram\n\n```\n                      |----------------|\n                      | dHealth Wallet |\n                      |----------------|\n                              |\n                      |----------------|\n                  ____| Strava OAuth   |____\n                  |   |----------------|   |\n                  |                        |\n            |------------|            |--------|     |------|\n            | Authorized |            | Denied |---->| Done |\n            |------------|            |--------|     |------|\n                  |\n          |-------------------|     |--------------|\n          | onActivityCreated |---->| isFirst(24h) |\n          |-------------------|     |--------------|\n                                           |\n                          |-----|          |          |-----|     |------|\n                          | Yes |----------|----------| No  |---->| Done |\n                          |-----|                     |-----|     |------|\n                             |\n                             |\n                    |-------------------|\n                    | Send NDAPP Reward |\n                    |-------------------|\n```\n\n## Components found here\n\nFollowing components are defined and exported with this library:\n\n| Class | Description |\n| --- | --- |\n| `HealthToEarn` | Mixin that displays a page to initiate the OAuth authentication of supported providers. |\n\n## Environment\n\nFirebase, and other Cloud Functions providers, lets you configure environment variables. This software requires the following environment configuration:\n\n```bash\ncd firebase-app\nfirebase functions:config:set \\\n  dhealth.node=\"http://dual-01.dhealth.cloud:3000\" \\\n  dhealth.account.secret=\"PRIVATE_KEY_HERE\" \\\n  strava.client_id=\"CID_HERE\" \\\n  strava.client_secret=\"SECRET_HERE\" \\\n  strava.verify_token=\"TOKEN_HERE\" \\\n  strava.oauth_url=\"OAUTH_URL_HERE\" \\\n  strava.subscribe_url=\"SUBSCRIBE_URL_HERE\" \\\n  strava.webhook_url=\"CALLBACK_URL_HERE\"\n```\n\nPlease, replace `PRIVATE_KEY_HERE` with the private key of the **payer** account. This account will send rewards to users when they register activities on Strava. Also, replace `CID_HERE` with your Strava App Client ID and `SECRET_HERE` with your Strava App Client Secret. You can find your Strava Client ID and Client Secret pair in your Strava Dashboard under `My API Application`. Then, *generate a random* verification token and replace `TOKEN_HERE` with the randomly generate verification token.\n\nFinally, replace `CALLBACK_URL_HERE` with your Webhook URL, this must be the URL that handles Strava webhook events (i.e. /webhook cloud function). Then, replace `OAUTH_URL_HERE` with the redirection URL that catches successful Strava OAuth authorization callbacks (i.e. /link cloud function) and also replace `SUBSCRIBE_URL_HERE` with the URL that handles Webhook subscription creation (i.e. /subscribe cloud function).\n\n### Service Accounts\n\nThis project requires to use a **service account** in to give the backend permissions in Firestore. A service account can be created in **Project Settings** > **Service Accounts**. After you click *Generate a new private key*, you will receive a `.json` file that contains the service account credential.\n\n:warning: Do not share this file and do not check it in a repository of any sort.\n\nAfter downloading the credential file, move it inside the firebase-app directory:\n\n```bash\nmv path/to/credential.json firebase-app/functions/.firebaseAuth.json\n```\n\n:warning: Note that the path and filename `firebase-app/functions/.firebaseAuth.json` must be respected, otherwise Firebase will not allow to read and write in Firestore.\n\n### Strava webhook subscription\n\nAfter deploying the functions *for the first time*, a subscription must be created to enable Strava webhooks, a subscription can be created with the following command:\n\n```bash\ncurl -X POST https://www.strava.com/api/v3/push_subscriptions \\\n      -F client_id=CID_HERE \\\n      -F client_secret=SECRET_HERE \\\n      -F 'callback_url=CALLBACK_URL_HERE' \\\n      -F 'verify_token=TOKEN_HERE'\n```\n\n:warning: Please, replace `CID_HERE` with your Strava App Client ID and `SECRET_HERE` with your Strava App Client Secret. You can find your Strava Client ID and Client Secret pair in your Strava Dashboard under `My API Application`. Then, *generate a random* verification token and replace `TOKEN_HERE` with the randomly generate verification token. Finally, replace `CALLBACK_URL_HERE` with your Webhook URL, this must be the URL that handles Strava webhook events (i.e. /webhook cloud function).\n\n## Development\n\nCloud functions can be tested using a local deployment using the `firebase-app/functions/package.json`. But we first need to configure the local emulator's configuration with the following commands:\n\n```bash\ncd firebase-app/functions\nfirebase functions:config:get > .runtimeconfig.json\ncd ../..\n```\n\nServing the cloud functions locally works by executing the following command from the *root directory of the project*:\n\n```bash\nnpm run serve\n```\n\nThis will deploy the cloud functions at the following URL: `http://localhost:5000/health-to-earn/us-central1/webhook`.\n\n## Deployment\n\nCloud functions can be deployed to Firebase using the following command: \n\n```bash\nfirebase deploy --only firestore:rules\nfirebase deploy --only functions\nfirebase deploy --only hosting\n```\n\nAlternatively, you can also deploy individual functions using - i.e. to deploy the cloud function `status`, you would execute the command: `firebase deploy --only functions:status`.\n\n:warning: Note that after you deployed the functions, you may have to update the [environment][#environment] configuration again and replace `OAUTH_URL` with the /authorize function URL, replace `SUBSCRIBE_URL_HERE` with the /subscribe function URL and replace `CALLBACK_URL_HERE` with the /webhook function URL.\n\n:warning: You must also update the **security rules** in Firestore such that it contains the content of `firebase-app/.rules`. This file opens reading operations to the public and writing operations are restricted to authenticated users. Deployment can be done with `firebase deploy --only firestore:rules`.\n\n## Webhook Endpoint\n\nTesting a newly deployed webhook event handler can be done with the below command. Please, note that this is using a test account for which the linked dHealth Account is a test account. The payout scheduler will/must never actually send funds to this address.\n\n```bash\ncurl -X POST https://us-central1-health-to-earn.cloudfunctions.net/webhook \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n      \"aspect_type\": \"create\",\n      \"event_time\": 1549560669,\n      \"object_id\": 6207413503,\n      \"object_type\": \"activity\",\n      \"owner_id\": YOUR_STRAVA_ID,\n      \"subscription_id\": YOUR_SUBSCRIPTION_ID\n    }'\n```\n\n## License\n\nCopyright 2021-present [Grégory Saive for dHealth Network][parent-url], All rights reserved.\n\nLicensed under the [LGPL v3.0](LICENSE)\n\n[self-url]: https://health2earn.com\n[parent-url]: https://dhealth.network\n[showcase-url]: https://health-to-earn.web.app\n[npm-url]: https://www.npmjs.com/package/@dhealthdapps/health-to-earn\n[npm-badge]: https://img.shields.io/npm/v/@dhealthdapps/health-to-earn\n[dl-badge]: https://img.shields.io/npm/dt/@dhealthdapps/health-to-earn\n","readmeFilename":"README.md"}