hansemannn / ti.onepassword

πŸ” Support the 1Password App Extension with Titanium Mobile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ti.OnePassword

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

1Password with Titanium

Requirements

  • iOS 11+
  • Titanium SDK 9.2.0+

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:

import OnePassword from 'ti.onepassword';

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

const isAvailable = OnePassword.isAppExtensionAvailable();

Request login credentials from 1Password:

OnePassword.findLoginForURLString({
    url: 'https://appcelerator.com',
    callback: event => {
        // Check if the operation succeeded
        if (!event.success) {
            alert(`Login could not be received: ${event.error}`);
            return;
        }

        // Success - Prefill the form fields
        usernameField.setValue(event.credentials.username);
        passwordField.setValue(event.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: event => {
        if (!event.success) {
            alert(`Credentials could not be added to 1Password: ${event.error}`);
            return;
        }

        // <-- Success case
    }
});

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: event => {
        if (!e.success) {
            alert(`Credentials could not be updated in 1Password: ${event.error}`);
            return;
        }

        // <-- Success case
    }
});

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!

About

πŸ” Support the 1Password App Extension with Titanium Mobile

License:Other


Languages

Language:Objective-C 87.4%Language:Python 11.4%Language:JavaScript 1.2%