1.15.6 • Published 3 months ago

@pluto-encrypted/database v1.15.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

Pluto-encrypted

Pluto Encrypted is a secure storage wrapper for (IndexDB, InMemory or LevelDB) and AtalaPrism (Pluto)

USAGE

To install simply run

npm i pluto-encrypted --save
# or with yarnyarn add pluto-encrypted

Usage

This package implements Pluto interface and is fully compatible with the Prism Agent (check-compatibility versions), in order to use it just create a database as follows.

DatabaseName is any string. Password is a 32 bytes buffer.

import { Database } from 'pluto-encrypted';
//You can use IndexDB any other storage that is compatible.
import IndexDB from "@pluto-encrypted/indexdb"; 
import { 
    getDefaultCollections,
    DIDCollection,
    DIDPairCollection,
    MediatorCollection,
    PrivateKeyColletion,
    CredentialCollection,
    CredentialRequestMetadataCollection,
    LinkSecretColletion,
    MessageColletion
} from "@pluto-encrypted/schemas";
const defaultPassword = new Uint8Array(32).fill(1);
const db = await Database.createEncrypted<{
    dids: DIDCollection;
    didpairs: DIDPairCollection;
    mediators: MediatorCollection;
    privatekeys: PrivateKeyColletion;
    credentials: CredentialCollection;
    credentialrequestmetadatas: CredentialRequestMetadataCollection;
    linksecrets: LinkSecretColletion;
    messages: MessageColletion;
}>(
   {
        name: `my-db`,
        encryptionKey: defaultPassword,
        storage: IndexDB,
        collections: getDefaultCollections()
    }
);
const messages = await db.getAllMessages();

Backup database into an unencrypted JSON string and restore from backup.

import { Database } from 'pluto-encrypted';
//You can use IndexDB any other storage that is compatible.
import IndexDB from "@pluto-encrypted/indexdb"; 
import { 
    getDefaultCollections,
    DIDCollection,
    DIDPairCollection,
    MediatorCollection,
    PrivateKeyColletion,
    CredentialCollection,
    CredentialRequestMetadataCollection,
    LinkSecretColletion,
    MessageColletion
} from "@pluto-encrypted/schemas";
const defaultPassword = new Uint8Array(32).fill(1);
const db = await Database.createEncrypted<{
    dids: DIDCollection;
    didpairs: DIDPairCollection;
    mediators: MediatorCollection;
    privatekeys: PrivateKeyColletion;
    credentials: CredentialCollection;
    credentialrequestmetadatas: CredentialRequestMetadataCollection;
    linksecrets: LinkSecretColletion;
    messages: MessageColletion;
}>(
   {
        name: "my-db",
        encryptionKey: defaultPassword,
        storage: IndexDB,
        collections: getDefaultCollections()
    }
);
const backup = await db.backup();
const restoredDatabase = await Database.createEncrypted<{
    dids: DIDCollection;
    didpairs: DIDPairCollection;
    mediators: MediatorCollection;
    privatekeys: PrivateKeyColletion;
    credentials: CredentialCollection;
    credentialrequestmetadatas: CredentialRequestMetadataCollection;
    linksecrets: LinkSecretColletion;
    messages: MessageColletion;
}>(
       {
        name: "my-db",
        encryptionKey: defaultPassword,
        storage: IndexDB,
        importData: backup,
        collections: getDefaultCollections()
    }
);
const messages = await restoredDatabase.getAllMessages();

If the database is later initialised with the wrong password the "createEncrypted" async function will throw an exception and will not let you decrypt any encrypted content.

QA & Documentation

StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines
1.15.6

3 months ago

1.15.4

3 months ago

1.15.5

3 months ago

1.15.3

3 months ago

1.15.2

3 months ago

1.15.0

4 months ago

1.15.1

4 months ago

1.14.1

4 months ago

1.14.0

4 months ago

1.14.2

4 months ago

1.12.0

4 months ago

1.13.2

4 months ago

2.0.0-rc.2

4 months ago

1.13.1

4 months ago

2.0.0-rc.3

4 months ago

1.13.0

4 months ago

1.13.3

4 months ago

2.0.0-rc.1

4 months ago

1.10.5

4 months ago

1.10.4

4 months ago

1.10.3

4 months ago

1.10.2

4 months ago

1.10.9

4 months ago

1.10.8

4 months ago

1.10.7

4 months ago

1.10.6

4 months ago

1.6.3

4 months ago

1.8.0

4 months ago

1.6.2

4 months ago

1.11.0-rc.1

4 months ago

1.6.0-rc.1

4 months ago

1.11.0

4 months ago

1.3.0-rc.5

4 months ago

1.11.1

4 months ago

1.9.0

4 months ago

1.7.0

4 months ago

1.5.0

4 months ago

1.3.0

4 months ago

1.12.0-rc.1

4 months ago

1.10.1

4 months ago

1.10.0

4 months ago

1.2.15-rc.3

4 months ago

1.2.15-rc.4

4 months ago

1.2.15-rc.2

4 months ago

1.3.0-rc.1

4 months ago

1.2.15-rc.1

4 months ago

1.2.15

4 months ago

1.2.12

4 months ago

1.2.13

4 months ago

1.2.14

4 months ago

1.2.8

4 months ago

1.2.10

4 months ago

1.2.11

4 months ago

1.2.9

4 months ago

1.2.0

5 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.23

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.11

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago

0.2.0

5 months ago

0.1.4

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.3

5 months ago

0.0.12

5 months ago

0.0.13

5 months ago

0.0.14

5 months ago

0.1.0

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.15

5 months ago

0.0.9

5 months ago

0.0.16

5 months ago

0.0.8

5 months ago

0.0.17

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.7

5 months ago

0.0.6

5 months ago

0.0.1

5 months ago