1.15.6 • Published 1 year ago

@pluto-encrypted/database v1.15.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year 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

1 year ago

1.15.4

1 year ago

1.15.5

1 year ago

1.15.3

1 year ago

1.15.2

1 year ago

1.15.0

1 year ago

1.15.1

1 year ago

1.14.1

1 year ago

1.14.0

1 year ago

1.14.2

1 year ago

1.12.0

1 year ago

1.13.2

1 year ago

2.0.0-rc.2

1 year ago

1.13.1

1 year ago

2.0.0-rc.3

1 year ago

1.13.0

1 year ago

1.13.3

1 year ago

2.0.0-rc.1

1 year ago

1.10.5

1 year ago

1.10.4

1 year ago

1.10.3

1 year ago

1.10.2

1 year ago

1.10.9

1 year ago

1.10.8

1 year ago

1.10.7

1 year ago

1.10.6

1 year ago

1.6.3

1 year ago

1.8.0

1 year ago

1.6.2

1 year ago

1.11.0-rc.1

1 year ago

1.6.0-rc.1

1 year ago

1.11.0

1 year ago

1.3.0-rc.5

1 year ago

1.11.1

1 year ago

1.9.0

1 year ago

1.7.0

1 year ago

1.5.0

1 year ago

1.3.0

1 year ago

1.12.0-rc.1

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.2.15-rc.3

1 year ago

1.2.15-rc.4

1 year ago

1.2.15-rc.2

1 year ago

1.3.0-rc.1

1 year ago

1.2.15-rc.1

1 year ago

1.2.15

1 year ago

1.2.12

1 year ago

1.2.13

1 year ago

1.2.14

1 year ago

1.2.8

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.9

1 year ago

1.2.0

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.11

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.0

1 year ago

0.1.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.15

2 years ago

0.0.9

2 years ago

0.0.16

2 years ago

0.0.8

2 years ago

0.0.17

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.1

2 years ago