Code Monkey home page Code Monkey logo

hansemannn.ti.onepassword's Introduction

Ti.OnePassword

Support for the AgileBits 1Password App Extention in Titanium Mobile to open 1Password for selecting credentials.

1Password with Titanium

Features

  • Check if 1Password is installed and can be used
  • Receive login credentials from 1Password
  • Store login credentials in 1Password
  • Change login credentials in 1Password

Usage

Add the following url-scheme to the <plist> section of your tiapp.xml like this:

<ios>
    <plist>
        <dict>
            <key>LSApplicationQueriesSchemes</key>
            <array>
            <string>org-appextension-feature-password-management</string>
            </array>
        </dict>
    </plist>
</ios>

Require the module:

var OnePassword = require("ti.onepassword");

Check if the application supports the 1Password App Extension to show/hide a custom 1Password button:

var isAvailable = OnePassword.isAppExtensionAvailable();

Request login credentials from 1Password:

OnePassword.findLoginForURLString({
    url: "https://appcelerator.com",
    callback: function(e) {
        // Check if the operation succeeded
        if (!e.success) {
            alert("Login could not be received: " + e.error);
            return;
        }

        // Success - Prefill the form fields
        usernameField.setValue(e.credentials.username);
        passwordField.setValue(e.credentials.password);
    }
});

Add a new login to 1Password:

OnePassword.storeLoginForURLString({
    url: "https://appcelerator.com",
    credentials: {
        username: "my_username",
        password: "my_password"
    },
    options: {
        password_min_length: 6,
        password_max_length: 18
    },
    callback: function(e) {
        if (!e.success) {
            alert("Credentials could not be added to 1Password: " + e.error);
            return;
        }

        // Success
    }
});

Change an existing login in 1Password:

OnePassword.changePasswordForLoginForURLString({
    url: "https://appcelerator.com",
    credentials: {
        username: "my_username",
        password: "my_new_password"
    },
    options: {
        password_min_length: 6,
        password_max_length: 18
    },
    callback: function(e) {
        if (!e.success) {
            alert("Credentials could not be added to 1Password: " + e.error);
            return;
        }

        // Success
    }
});

Available credentials

  • url_string
  • username
  • password
  • totp
  • login_title
  • notes
  • section_title
  • fields
  • returned_fields
  • old_password
  • password_generator_options

Available options

  • password_min_length
  • password_max_length
  • password_require_digits
  • password_require_symbols
  • password_forbidden_characters

Example

Check example/app.js for a basic example.

Author

Hans Knoechel (@hansemannnn / Web)

License

Apache 2.0

Contributing

Code contributions are greatly appreciated, please submit a new pull request!

hansemannn.ti.onepassword's People

Contributors

hansemannn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.