aboutsummaryrefslogtreecommitdiffstats
path: root/library/sodium-plus/index.js
blob: 800347f6f5d5d9ab746879237fe12955f13675a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module.exports = {
    /**
     * This is only meant to be used for advanced users.
     *
     * A backend object can be passed to the SodiumPlus constructor.
     *
     * @param {string} type
     * @return {Backend}
     * @throws {SodiumError}
     * @throws {Error}
     */
    getBackendObject: (type = '') => {
        if (type === 'SodiumNative') {
            // This one may error out. You should catch it in your code.
            // We won't here. Use the `await SodiumPlus.auto()` API instead!
            return require('./lib/backend/sodiumnative');
        } else if (type === 'LibsodiumWrappers') {
            return require('./lib/backend/libsodium-wrappers');
        } else if (type.length === 0) {
            return require('./lib/backend');
        }

        // Default: Throw a SodiumError
        let SodiumError = require('./lib/sodium-error');
        throw new SodiumError(`Unrecognized backend type: ${type}`);
    },
    CryptographyKey: require('./lib/cryptography-key'),
    Ed25519PublicKey: require('./lib/keytypes/ed25519pk'),
    Ed25519SecretKey: require('./lib/keytypes/ed25519sk'),
    SodiumError: require('./lib/sodium-error'),
    SodiumPlus: require('./lib/sodiumplus'),
    SodiumPolyfill: require('./lib/polyfill'),
    SodiumUtil: require('./lib/util'),
    X25519PublicKey: require('./lib/keytypes/x25519pk'),
    X25519SecretKey: require('./lib/keytypes/x25519sk')
};