0.2.27 • Published 11 months ago

@smontero/hashed-confidential-docs v0.2.27

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Hashed Confidential Docs Client API

Enables the usage of the Hashed Confidential docs services by client applications.

To install the hashed private client api run the following command:

npm i --save @smontero/hashed-confidential-docs

Access to most of the functionality is done through the HashedConfidentailDocs object which enables its configuration and provides access to the different API objects:

import { HashedConfidentialDocs } from '@smontero/hashed-confidential-docs'

A new instance of the HashedConfidentialDocs class has to be created passing in the ipfs url, ipfs auth header, polkadot service class instance and a faucet instance:

const hcd = new HashedConfidentialDocs({
    ipfsURL: 'https://ipfs.infura.io:5001',
    ipfsAuthHeader: `Basic ${Buffer.from(`${process.env.IPFS_PROJECT_ID}:${process.env.IPFS_PROJECT_SECRET}`).toString('base64')}`,
    polkadot,
    faucet
  })

Then the user has to be logged in to hashed confidential docs, to login the user a VaultAuthProvider is required, the VaultAuthProvider used depends on how the user is login in to the system ex. username/password, google sign in or a native wallet, the current auth channels are:

The creation and initialization of a vaultAuthProvider is done through creation methods which are exported from this package while the classes themselves are not.

  const vaultAuthProvider = await createPasswordVaultAuthProvider({
        authName, // the name to identify this auth channel
        jwt, // the JSON Web Token generated by the authentication channel
        faucetServerUrl, //the url for the hashed faucet server
        password
      })
const vaultAuthProvider = await createGoogleVaultAuthProvider({
      authName, // the name to identify this auth channel
      jwt, // the JSON Web Token generated by the authentication channel
      faucetServerUrl, //the url for the hashed faucet server
      googleDrive //instance of the google drive service class
    })

During the VaultAuthProvider creation, the jwt token is verified, after the creation of the VaultAuthProvider the decoded can be accessed as follows:

vaultAuthProvider.decodedJWT

await hcd.login(vaultAuthProvider)

Its important to note that the polkadot service class instance passed in to the hashed confidential docs will be configured with a VaultWallet when the user is logged in, that will enable this instance to be used to call extrinsics and sign on behalf of the user.

Once logged in the services provided by the OwnedData,SharedData and Group objects can be accessed.

OwnedData services

  • add: Store a payload(object or File) in the hashed private service
const ownedData = await hcd.ownedData().add({
    name: 'name1',
    description: 'desc1',
    payload: {
      prop1: 1,
      prop2: 'str1'
    }
  })
  • viewByCID: View a stored payload by owned data cid, returns the deciphered payload(object or File)
const ownedData = await hcd.ownedData().viewByCID(cid)

SharedData services

  • share: Share the specified existing owned data record with another user
let sharedData = await hp.sharedData().share({
  toUserAddress: '5FSuxe2q7qCYKie8yqmM56U4ovD1YtBb3DoPzGKjwZ98vxua',
  name: 'name1',
  description: 'desc1',
  payload: {
    prop1: 1,
    prop2: 'str1'
  }
})
  • viewByCID: View a stored payload by shared data cid, returns the deciphered payload(object or File)
const ownedData = await hcd.sharedData().viewByCID(cid)

Group services

  • createGroup: Creates a new group with the logged in user as the owner
const group = await hcd.group().createGroup('test1')
  • addGroupMember: Adds a member to the specified group, only owners and admins are able to add members
await hcd.group().addGroupMember({
      groupAddress: group.group,
      memberAddress,
      role: GroupRole.MEMBER
    })

Export Vault

const exporter = BrowserDownloadExporter()
await hcd.vault().exportVault(exporter)
0.2.27

11 months ago

0.2.26

11 months ago

0.2.25

12 months ago

0.2.24

12 months ago

0.2.23

1 year ago

0.2.22

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.0

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago