Skip to content

Commit

Permalink
Merge pull request #11 from verida/feature/merge_with_client_ts_1_1_13
Browse files Browse the repository at this point in the history
Merge with client-ts v1.1.13
  • Loading branch information
pkhien95 authored Mar 10, 2022
2 parents 30b84ab + 3e6d390 commit 996560d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 185 deletions.
6 changes: 6 additions & 0 deletions client-rn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

2022-03-10 (v1.1.13)
-------------------

- Changes to support documentation generation

2022-02-27 (v1.1.12)
-------------------

Expand Down
3 changes: 0 additions & 3 deletions client-rn/README.api.md

This file was deleted.

113 changes: 3 additions & 110 deletions client-rn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,127 +15,20 @@ yarn add @verida/client-ts

### Context Initializing (Web - SSO)

Initialize a connection to the Verida netork using a private key stored on the user's mobile device using the Verida Vault.
See the [Client SDK Getting Started Guide](https://developers.verida.io/docs/client-sdk/getting-started) in the [Developer Docs](https://developers.verida.io/docs/client-sdk).

This easy to use integration method allows a user to scan a QR code to sign into your application. If the user doesn't have the Verida Vault installed, they will be prompted to install it. Existing users will be prompted to authorize your application to access encrypted storage for that application.

I also requires installing the [@verida/account-web-vault](packages/account-web-vault) dependency:

```
yarn add @verida/account-web-vault
```

Here's how you initialize an application:

```
import { Network, EnvironmentType } from '@verida/client-ts'
import { VaultAccount } from '@verida/account-web-vault'
const VERIDA_ENVIRONMENT = EnvironmentType.TESTNET
const CONTEXT_NAME = 'My Application Context Name'
const VERIDA_TESTNET_DEFAULT_SERVER = 'https://db.testnet.verida.io:5002/'
const account = new VaultAccount({
defaultDatabaseServer: {
type: 'VeridaDatabase',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
},
defaultMessageServer: {
type: 'VeridaMessage',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
},
})
const context = Network.connect({
client: {
environment: VERIDA_ENVIRONMENT
},
account: account,
context: {
name: CONTEXT_NAME
}
})
```

### Context Initializing (Server / Mobile)

Initialize a connection to the Verida network with an existing private key.

In this example we are providing default Verida servers pointing to `http://localhost:5000/`. These will need to point to any default server infrastructure you provide to your users by spinning up instances of `@verida/storage-node`.

```
import { Network, EnvironmentType } from '@verida/client-ts'
import { AutoAccount } from '@verida/account-node'
const VERIDA_ENVIRONMENT = EnvironmentType.TESTNET
const CONTEXT_NAME = 'My Application Context Name'
const VERIDA_TESTNET_DEFAULT_SERVER = 'https://db.testnet.verida.io:5002/'
const context = Network.connect({
context: {
name: CONTEXT_NAME
},
client: {
environment: VERIDA_ENVIRONMENT
},
account: new AutoAccount({
defaultDatabaseServer: {
type: 'VeridaDatabase',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
},
defaultMessageServer: {
type: 'VeridaMessage',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
}
}, {
privateKey: '0x...' // or mnemonic seed phrase
})
})
See the [Authentication with a Private Key](https://developers.verida.io/docs/client-sdk/authentication#2-private-key).

```

### Advanced Initializing

In your application, include the dependency and create a new client network instance:
See the [Advanced Authentication](https://developers.verida.io/docs/client-sdk/authentication#2-private-key).

```
import { Client, EnvironmentType } from '@verida/client-ts'
import { AutoAccount } from '@verida/account-node'
const VERIDA_ENVIRONMENT = EnvironmentType.TESTNET
const CONTEXT_NAME = 'My Application Context Name'
const VERIDA_TESTNET_DEFAULT_SERVER = 'https://db.testnet.verida.io:5002/'
// establish a network connection
const client = new Client({
environment: VERIDA_ENVIRONMENT
})
// create a Verida account instance that wraps the authorized Ceramic connection
// The `AutoAccount` instance will automatically sign any consent messages
const account = new AutoAccount({
defaultDatabaseServer: {
type: 'VeridaDatabase',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
},
defaultMessageServer: {
type: 'VeridaMessage',
endpointUri: VERIDA_TESTNET_DEFAULT_SERVER
}
}, {
environment: VERIDA_ENVIRONMENT,
privateKey: '0x...'
})
// Connect the Verida account to the Verida client
await client.connect(account)
// Open an application context (forcing creation of a new context if it doesn't already exist)
const context = await client.openContext(CONTEXT_NAME, true)
// Open a database
const database = await context.openDatabase('my_database')
```

## Tests

Expand Down
23 changes: 0 additions & 23 deletions client-rn/generate-and-deploy-docs.sh

This file was deleted.

38 changes: 0 additions & 38 deletions client-rn/jsdoc.json

This file was deleted.

18 changes: 8 additions & 10 deletions client-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@verida/client-rn",
"version": "1.1.12",
"version": "1.1.13",
"main": "dist/src/index.js",
"license": "ISC",
"directories": {
Expand All @@ -20,14 +20,14 @@
"@ceramicnetwork/http-client": "^1.3.0",
"@craftzdog/pouchdb-core-react-native": "^7.2.2",
"@tradle/react-native-http": "^2.0.0",
"@verida/account": "^1.1.8",
"@verida/account-node": "^1.1.8",
"@verida/did-client": "^0.1.7",
"@verida/did-document": "^1.0.4",
"@verida/encryption-utils": "^1.1.2",
"@verida/keyring": "^1.1.2",
"@verida/account": "^1.1.9",
"@verida/account-node": "^1.1.9",
"@verida/did-client": "^0.1.8",
"@verida/did-document": "^1.0.5",
"@verida/encryption-utils": "^1.1.3",
"@verida/keyring": "^1.1.3",
"@verida/pouchdb-replication-react-native": "^7.0.0-prerelease",
"@verida/storage-link": "^1.1.7",
"@verida/storage-link": "^1.1.8",
"ajv": "^8.6.3",
"ajv-formats": "^2.1.1",
"assert": "^1.1.1",
Expand Down Expand Up @@ -79,9 +79,7 @@
"@types/lodash": "^4.14.179",
"@types/node": "^16.7.12",
"@types/pouchdb": "^6.4.0",
"better-docs": "^2.3.2",
"dependency-cruiser": "^11.3.0",
"jsdoc": "^3.6.7",
"mocha": "^8.2.1",
"ts-mocha": "^8.0.0",
"ts-node": "^9.1.1",
Expand Down
2 changes: 1 addition & 1 deletion client-rn/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class Client {
*
* @param did
* @param contextName
* @returns <Profile | undefined>
* @returns `<Profile | undefined>`
*/
public async openPublicProfile(
did: string,
Expand Down
1 change: 1 addition & 0 deletions client-rn/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"declaration": true,
"skipLibCheck": true, // disable TS checking of dependencies
"outDir": "./dist",
"sourceMap": true,
"strict": true,
"lib": [
"es5",
Expand Down

0 comments on commit 996560d

Please sign in to comment.