{"id":22519432,"url":"https://github.com/hydrogen-dev/raindrop-sdk-js","last_synced_at":"2025-08-03T18:32:27.571Z","repository":{"id":55658316,"uuid":"127971826","full_name":"hydrogen-dev/raindrop-sdk-js","owner":"hydrogen-dev","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-14T20:33:40.000Z","size":1124,"stargazers_count":22,"open_issues_count":3,"forks_count":6,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-12-01T08:44:13.845Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hydrogen-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-03T21:40:06.000Z","updated_at":"2022-09-02T16:58:40.000Z","dependencies_parsed_at":"2022-08-15T05:50:17.987Z","dependency_job_id":null,"html_url":"https://github.com/hydrogen-dev/raindrop-sdk-js","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen-dev%2Fraindrop-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen-dev%2Fraindrop-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen-dev%2Fraindrop-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen-dev%2Fraindrop-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hydrogen-dev","download_url":"https://codeload.github.com/hydrogen-dev/raindrop-sdk-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228558671,"owners_count":17936725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T04:20:17.234Z","updated_at":"2024-12-07T04:20:19.590Z","avatar_url":"https://github.com/hydrogen-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hydro Raindrop\nThis package provides a suite of convenience functions intended to simplify the integration of Hydro's [Raindrop authentication](https://www.hydrogenplatform.com/hydro) into your project. An equivalent [Python SDK](https://github.com/hydrogen-dev/raindrop-sdk-python) is also available. More information, including detailed API documentation, is available in the [Raindrop documentation](https://www.hydrogenplatform.com/docs/hydro/v1/#Raindrop). Raindrop comes in two flavors:\n\n## Client-side Raindrop\nClient-side Raindrop is a next-gen 2FA solution. We've open-sourced the [code powering Client-side Raindrop](https://github.com/hydrogen-dev/smart-contracts/tree/master/client-raindrop).\n\n\n## Server-side Raindrop\nServer-side Raindrop is an enterprise-level security protocol to secure APIs and other shared resources. We've open-sourced the [code powering Server-side Raindrop](https://github.com/hydrogen-dev/smart-contracts/tree/master/hydro-token-and-raindrop-enterprise).\n\n\n## Installation\n### Recommended\nInstall [raindrop on npm](https://www.npmjs.com/package/@hydrogenplatform/raindrop):\n```shell\nnpm install -S @hydrogenplatform/raindrop\n```\n\n### Manual\nYou can also install manually:\n- `git clone https://github.com/hydrogen-dev/raindrop-sdk-js.git`\n- `cd raindrop-sdk-js`\n- `npm install`\n\n\n## Usage\nThe `raindrop` package exposes two objects: `raindrop.client` and `raindrop.server`. To start making API calls, you'll need to instantiate a `RaindropPartner` object for the module you'd like to use. The SDK will automatically fetch you an [OAuth token](https://www.hydrogenplatform.com/docs/hydro/v1/#Authentication), and set [your environment](https://www.hydrogenplatform.com/docs/hydro/v1/#Environment).\n\n```javascript\nconst raindrop = require(\"@hydrogenplatform/raindrop\")\n```\n\n## Generic `RaindropPartner` Functions\n### constructor `new RaindropPartner(config)`\nTo instantiate a new RaindropPartner object in the `client` or `server` modules, you must pass a config object with the following values:\n- `config`\n  - `environment` (required): `Sandbox` | `Production` to set your environment\n  - `clientId` (required): Your OAuth id for the Hydro API\n  - `clientSecret` (required): Your OAuth secret for the Hydro API\n  - `applicationId` (required for `client` calls): Your application id for the Hydro API\n  - `verbose` (optional): `true` | `false` turns more detailed error reporting on | off\n\n### `RaindropPartnerObject.refreshToken()`\nManually refreshes OAuth token.\n\n### `RaindropPartnerObject.transactionStatus(transactionHash)`\nThis function returns true when the transaction referenced by `transactionHash` has been included in a block on the Ethereum blockchain (Rinkeby if the environment is `Sandbox`, Mainnet if the environment is `Production`).\n- `transactionHash` (required): Hash of a transaction\n\n## Generic `raindrop.client` Functions\n\n### `generateMessage()`\nGenerates a random 6-digit string of integers for users to sign. Uses system-level CSPRNG.\n\n## `raindrop.client.RaindropPartner` Functions\nClient-side Raindrop initialization code will look like:\n\n```javascript\n// Client-side Raindrop Setup\nconst ClientRaindropPartner = new raindrop.client.RaindropPartner({\n    environment: \"Sandbox\",\n    clientId: \"yourId\",\n    clientSecret: \"yourSecret\",\n    applicationId: \"yourApplicationId\"\n})\n```\n\n### `registerUser(HydroID)`\nShould be called when a user elects to use Raindrop Client for the first time with your application.\n- `HydroID`: the new user's HydroID (the one they used when signing up for Hydro mobile app)\n\n### `verifySignature(HydroID, message)`\nShould be called each time you need to verify whether a user has signed a message.\n- `HydroID`: the HydroID of the user that is meant to have signed `message`\n- `message`: a message generated from `generateMessage()` (or any 6-digit numeric code)\n\nReturns a response object that looks like: `{verified: true, data: {...}}`. The `verified` parameter will only be `true` for successful verification attempts.\n\n### `unregisterUser(HydroID)`\nShould be called when a user disables Client-side Raindrop with your application.\n- `HydroID`: the user's HydroID (the one they used when signing up for Hydro mobile app)\n\n## `raindrop.server.RaindropPartner` Functions\nServer-side Raindrop initialization code will look like:\n\n```javascript\n// Server-side Raindrop Setup\nconst ServerRaindropPartner = new raindrop.server.RaindropPartner({\n  environment: \"Sandbox\",\n  clientId: \"yourId\",\n  clientSecret: \"yourSecret\"\n})\n```\n\n### `whitelist(addressToWhitelist)`\nA one-time call that whitelists a user to authenticate with your API via Server-side Raindrop.\n- `addressToWhitelist`: The Ethereum address of the user you're whitelisting\n\n### `requestChallenge(hydroAddressId)`\nInitiate an authentication attempt on behalf of the user associated with `hydroAddressId`.\n- `hydroAddressId`: the `hydro_address_id` of the authenticating user\n\n### `authenticate(hydroAddressId)`\nChecks whether the user correctly performed the raindrop.\n- `hydroAddressId`: the `hydro_address_id` of the user who claims to be authenticated\n\nReturns a response object that looks like: `{authenticated: true, data: {...}}`. The `authenticated` parameter will only be `true` for successful authentication attempts.\n\n## Copyright \u0026 License\nCopyright 2018 The Hydrogen Technology Corporation under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydrogen-dev%2Fraindrop-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhydrogen-dev%2Fraindrop-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydrogen-dev%2Fraindrop-sdk-js/lists"}