## Javascript: Importing libsecret

In javascript use the standard introspection import mechanism to get at libsecret:

    1
    2
    3
    4
    5
    const Secret = imports.gi.Secret;

    // ... and here's a sample line of code which uses the import
    var schema = new Secret.Schema.new("org.mock.Schema",
        Secret.SchemaFlags.NONE, { "name", Secret.SchemaAttributeType.STRING });

Some parts of the libsecret API are not yet stable. It is not recommended that you use these unstable parts from javascript. Your code will break when the unstable API changes, and due to the lack of a compiler you will have no way of knowing when it does. If you must use the unstable API, you would do it like this:

    1
    2
    3
    4
    5
    // Warning: if you use the unstable API from javascript, your're going to have a bad time
    const SecretUnstable = imports.gi.SecretUnstable;

    // ... and a here's sample line of code which uses the import
    var collection = SecretUnstable.Collection.for_alias(null, "default", null);