Ionic-native: @ionic-native/secure-storage secureDevice() method is inaccessible when device is not secure

Created on 27 Apr 2018  路  7Comments  路  Source: ionic-team/ionic-native

I'm submitting a ...
[x] bug report
[ ] feature request

Current behavior:
If device is not properly secured when instantiating SecureStorage, it will reject with Device not secure error. Any developer would then like to direct the user to the screen-lock page of the device to apply screen lock. Secure storage pagkage has a method exactly for that - secureDevice(). PROBLEM: secureDevice() method is in SecureStorageObject's instance which already rejected because device was not secure.
What is happening is SecureStorage raises an error that device is not secure but does not provide any means of directing user to the screen-lock page. Yes it has secureDevice() method which does exactly that but this method is unreachable in case your device is not secure which is counterintuitive. If users device is secure then you could access secureDevice() without problems but there's no need to.

Expected behavior:
The secureDevice() method should be on SecureStorage class in order to be accessible when calling .create() method on it if it rejects.

Steps to reproduce:
Use the latest ionic blank app and try to access secureDevice function when error thrown calling .create().

Related code:

var ss = this.secureStorage.create('MySecureStorage')
                .then((storage: SecureStorageObject) => {
                    storage.set('key', 'value')
                        .then(
                        () => console.log('success'),
                        (e) => console.log('error');
                        );
                }).catch((err) => {
                    console.error('The device is not secured');
                    //secureDevice() not available here
                });

Other information:
@ionic-native\secure-storage type definition file also specifies that secureDevice() is on SecureStorageObject which is inaccessible if device is not secure.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 
    Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2 
    Node              : v8.11.1
    npm               : 5.6.0 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b 

Most helpful comment

ionic 4 is released and the issue is still not resolved. this issue can easily be fixed by returning the secure instance along with error in rejection.

All 7 comments

I am experiencing this issue as well.
This issue has been reported before and has been closed without any fix.

1625

Appreciate if Ionic can fix this soon.

ionic 4 is released and the issue is still not resolved. this issue can easily be fixed by returning the secure instance along with error in rejection.

@danielsogl it seems that you're one of the current contributors, this is a pretty serious issue since the existing design is unusable, and this plugin is still listed in the official docs so it should still be maintained. If not you, can anyone look into this? Thanks.

I ended up calling secure storage directly without using Ionic Native

@malwatte that's the current workaround but ionic team still needs to fix this, it's not acceptable that they have unusable design when they are pushing for enterprise adoption.

Yeah. I have applied dirty workarounds for dozens of Ionic 3 bugs. Looks like they are busy with releasing new versions without fixing existing issues. I think I made a wrong decision moving to Ionic 3. Should have gone with React Native instead.

Sent a PR few minutes ago, i hope that they will merge it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajanshahsa picture rajanshahsa  路  3Comments

goleary picture goleary  路  3Comments

mateo666 picture mateo666  路  3Comments

ihadeed picture ihadeed  路  4Comments

jgw96 picture jgw96  路  3Comments