martinkasa / capacitor-secure-storage-plugin

Capacitor plugin for storing string values securly on iOS and Android.
MIT License
153 stars 55 forks source link

Android SecureStoragePlugin.keys() returns "[Ljava.lang.String;" instead of an array of strings. #29

Closed Mankee closed 3 years ago

Mankee commented 3 years ago

The value being returned by SecureStoragePlugin.keys() is the string literal "[Ljava.lang.String;" instead of an array of strings. This is broken for both android and iOS. I have forked the the repo to add a simple fix where I just call Arrays.toString(keys) to get the values. This is not ideal however because this is still not a proper stringified JSON object.

Am I doing something wrong? I am on "capacitor-secure-storage-plugin": "^0.5.0", @capacitor/android": "^2.4.4", "@capacitor/core": "^2.4.4", and "@capacitor/ios": "^2.4.4".

below is a hack I am using to get the actual string values.

public JSObject _keys() {
  String[] keys = this.passwordStorageHelper.keys();
  JSObject ret = new JSObject();
  ret.put("value", Arrays.toString(keys));
  return ret;
}
martinkasa commented 3 years ago

Thanks for reporting the issue.