Socket
Socket
Sign inDemoInstall

@gustash/react-native-smart-lock

Package Overview
Dependencies
531
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gustash/react-native-smart-lock

Google Smart Lock for React Native


Version published
Weekly downloads
12
decreased by-42.86%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React Native Smart Lock

This package exposes Google Smart Lock for auto sign-in based on saved credentials.

Getting started

$ npm install @gustash/react-native-smart-lock --save

Mostly automatic installation (RN < 0.60)

$ react-native link @gustash/react-native-smart-lock

Usage

Request Credentials

import SmartLock from '@gustash/react-native-smart-lock';

async function request() {
  // You can also send a client server id as a paramenter as well
  // const {error, success, ...credentials} = await SmartLock.request('some.server.id');
  const {error, success, ...credentials} = await SmartLock.request();

  if (error) {
    console.error(error);
    return;
  }

  if (success) {
    // Account found. Do something with credentials.
    const {
      id,
      password,
      accountType,
      familyName,
      givenName,
      name,
      profilePictureUri,
      idTokens,
    } = credentials;
  }
}

Save Credentials

import SmartLock from '@gustash/react-native-smart-lock';

async function save() {
  const credentials = {
    id: 'some@email.com',
    profilePictureUri:
      'https://api.adorable.io/avatars/285/abott@adorable.png',
    name: 'John Doe',
    password: 'password',
  };

  const error = await SmartLock.save(credentials);

  // The save method might be canceled if the system wants to give priority
  // to the password manager UI instead.
  if (error && error !== 'canceled') {
    console.error(error);
  }
}

Delete Credentials

import SmartLock from '@gustash/react-native-smart-lock';

async function deleteCredential() {
  const error = await SmartLock.delete('some@email.com');

  if (error) {
    console.error(error);
  }
}

Disable Auto Sign-in

import SmartLock from '@gustash/react-native-smart-lock';

// This disables request() until a new save() is called.
// You should call this on logout to allow the user to change accounts, for example.
SmartLock.disableAutoSignIn();

Keywords

FAQs

Last updated on 30 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc