{"id":18878581,"url":"https://github.com/verida/vault-auth-client","last_synced_at":"2025-04-14T18:32:16.972Z","repository":{"id":40694046,"uuid":"299855488","full_name":"verida/vault-auth-client","owner":"verida","description":null,"archived":true,"fork":false,"pushed_at":"2021-09-15T01:49:10.000Z","size":677,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-20T12:47:24.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/verida.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-30T08:25:47.000Z","updated_at":"2024-05-30T00:43:18.000Z","dependencies_parsed_at":"2022-09-07T10:41:21.687Z","dependency_job_id":null,"html_url":"https://github.com/verida/vault-auth-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verida%2Fvault-auth-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verida%2Fvault-auth-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verida%2Fvault-auth-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/verida%2Fvault-auth-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/verida","download_url":"https://codeload.github.com/verida/vault-auth-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248936880,"owners_count":21186119,"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-11-08T06:28:10.702Z","updated_at":"2025-04-14T18:32:16.577Z","avatar_url":"https://github.com/verida.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Verida Auth Client \n\n## Usage\n\n```js\nimport { veridaVaultLogin } from '@verida/vault-auth-client'\n\n// Unique name of application\nconst APP_NAME = 'My Company: My Application'\n\n// URI of the auth server. Verida provides a default server for testnet, but you can spin\n// up your own using https://github.com/verida/vault-auth-server\nconst WSS_URI = 'wss://auth-server.testnet.verida.io:7001'\n\n// URL of the logo to display in the Verida Vault mobile application\n// when the user is authenticating\nconst LOGO_URL = ''\n\nveridaVaultLogin({\n      serverUri: WSS_URI,\n      appName: APP_NAME,\n      logoUrl: LOGO_URL,\n      callback: async (response) =\u003e {\n          // instantiate a Verida client using the signature that unlocks this application's\n          // secure context of databases and messages\n          const verida = new Verida({\n            did: response.did,\n            signature: response.signature,\n            appName: APP_NAME\n          })\n          \n          // connect the user\n          await verida.connect(true)\n\n          // The user is now authenticated\n          // The verida instance can now be used to open databases, datastores, access the application inbox etc.\n        }\n    })\n```\n\n## Build scripts\n\n\u003e `Note:` Windows users ensure you open your bash terminal before running any scripts to work properly .\n\n\n- MacOSX: `npm run build`\n- Windows: `npm run build.bash`\n\n## Getting started with Verida Auth Client Demo \n\n\n\n### Connecting to your vault \n\n```js\nimport Verida from '@verida/datastore';\nimport { veridaVaultLogin } from '@verida/vault-auth-client';\n\n\n// Unique name of application\nconst APP_NAME = 'My Company: My Application'\n\n// URI of the auth server. Verida provides a default server for testnet, but you can spin\n// up your own using https://github.com/verida/vault-auth-server\nconst WSS_URI = 'wss://auth-server.testnet.verida.io:7001'\n\n// URL of the logo to display in the Verida Vault mobile application\n// when the user is authenticating\nconst LOGO_URL = ''\n\n\n   veridaVaultLogin({\n      loginUri: WSS_URI,\n      serverUri: SERVER_URI,\n      appName: CLIENT_AUTH_NAME,\n      logoUrl: LOGO_URL,\n      callback: async (response) =\u003e {\n          const veridaDApp = new Verida({\n            did: response.did,\n            signature: response.signature,\n            appName: CLIENT_AUTH_NAME\n          })\n          await veridaDApp.connect(true)\n          const dataStore = await window.veridaDApp.openDatastore(DATASTORE_SCHEMA)\n          const notes = await dataStore.getMany();\n\n\n          const profileInstance = await window.veridaDApp.openProfile(response.did, 'Verida: Vault');\n\n          const data = await profileInstance.getMany()\n          const userProfile = data.reduce((result, item) =\u003e {\n            result[item.key] = item.value;\n            return result;\n          }, {});\n      }\n    })\n\n\n```\n\n 1. The `VeridaVaultLogin` function accepts an object with the following  fields\n\n- `loginUri` -  The vault login Url,\n-  `serverUri` - URI of the auth server. Verida provides a default server for testnet, but you can spin\nup your own using https://github.com/verida/vault-auth-server\n-  `appName`  -  Custom application name\n-  `logoUrl` - URL of the logo to display in the Verida Vault mobile application when the user is authenticating ``optional``\n-  `callback` - A function that returns the decrypted user data .\n\n2. When the `veridaVaultLogin` function is been called it will open a modal with a QR code which a user scans to allow access from the requesting application.\n\n`see example below:`\n\n![demo image](https://assets.verida.io/verida_logo.svg)\n\n3. Create an instance of the verida App using the response in the callback function from the `VeridaVaultLogin` and a open datastore see example:\n\n```js\n\n    const veridaDApp = new Verida({\n      did: response.did,\n      signature: response.signature,\n      appName: CLIENT_AUTH_NAME\n    })\n\n    const dataStore = await window.veridaDApp.openDatastore(DATASTORE_SCHEMA)\n    const notes = await dataStore.getMany();   \n\n    await veridaDApp.connect(true)\n\n```\n\n3. Accessing the user public profile data\n\n```js\n\n    const profileInstance = await window.veridaDApp.openProfile(response.did, 'Verida: Vault');\n    const data = await profileInstance.getMany()\n    const userProfile = data.reduce((result, item) =\u003e {\n      result[item.key] = item.value;\n      return result;\n    }, {});\n\n```\n\n4. Listen for real time changes in the vault when ever user edits their public profile information\n\n`see example code below:`\n\n```js\n    const db = await profileInstance._store.getDb();\n    const dbInstance = await db.getInstance();\n    dbInstance.changes({\n        since: 'now',\n        live: true\n    }).on('change', async function (info) {\n        const row = await db.get(info.id, {\n          rev: info.changes[0].rev\n        });\n          \n        // updated user data\n        console.log(row);\n    });\n```\n\n\n## Using Verida Custom Button\n\nVerida suggests you to use the following buttons for SSO login (Single Sign On) to maintain a consistent branding. You can save these images to your server cloud in order to use it on your application.\n\nConnect with Verida (Light):\n\n![Verida Connect Light](https://assets.verida.io/connect_with_verida_light.png)\n\nConnect with Verida (Dark):\n\n![Verida Connect Dark](https://assets.verida.io/connect_with_verida_dark.png)\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverida%2Fvault-auth-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverida%2Fvault-auth-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverida%2Fvault-auth-client/lists"}