Skip to content

Secrets plugin api#1902

Draft
RohitKushvaha01 wants to merge 2 commits intoAcode-Foundation:mainfrom
RohitKushvaha01:main
Draft

Secrets plugin api#1902
RohitKushvaha01 wants to merge 2 commits intoAcode-Foundation:mainfrom
RohitKushvaha01:main

Conversation

@RohitKushvaha01
Copy link
Member

No description provided.

@RohitKushvaha01 RohitKushvaha01 marked this pull request as draft February 26, 2026 09:02
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Adds a secrets API that allows plugins to securely store and retrieve encrypted key-value pairs using EncryptedPreferenceManager. The implementation adds get_secret and set_secret actions to the Cordova plugin bridge.

Critical Issues Found:

  • Missing required imports in Tee.java - code will not compile without android.content.Context, org.apache.cordova.CordovaInterface, and org.apache.cordova.CordovaWebView
  • Inconsistent API design in PluginContext.js - methods require redundant token parameter instead of using this.uuid like existing grantedPermission() and listAllPermissions() methods

Confidence Score: 1/5

  • Critical compilation errors and API design flaws make this PR unsafe to merge
  • Missing imports will prevent compilation, and the inconsistent API design will cause confusion and potential runtime errors when developers try to use the new methods
  • Both files need immediate attention - Tee.java requires imports and PluginContext.js needs API redesign

Important Files Changed

Filename Overview
src/plugins/pluginContext/src/android/Tee.java Added secrets API with get_secret and set_secret actions, but missing required imports for Context, CordovaInterface, and CordovaWebView - will not compile
src/plugins/pluginContext/www/PluginContext.js Added getSecret and setSecret methods with inconsistent API - requires redundant token parameter instead of using this.uuid like other methods

Sequence Diagram

sequenceDiagram
    participant Plugin as Plugin Code
    participant PC as PluginContext.js
    participant Cordova as Cordova Bridge
    participant Tee as Tee.java
    participant EPM as EncryptedPreferenceManager
    
    Note over Plugin,EPM: Set Secret Flow
    Plugin->>PC: setSecret(token, key, value)
    PC->>Cordova: exec("Tee", "set_secret", [token, key, value])
    Cordova->>Tee: execute("set_secret", args)
    Tee->>Tee: getPluginIdFromToken(token)
    Tee->>EPM: new EncryptedPreferenceManager(context, pluginId)
    Tee->>EPM: setString(key, value)
    EPM-->>Tee: encrypted and stored
    Tee-->>Cordova: success callback
    Cordova-->>PC: resolve()
    PC-->>Plugin: Promise resolved
    
    Note over Plugin,EPM: Get Secret Flow
    Plugin->>PC: getSecret(token, key, defaultValue)
    PC->>Cordova: exec("Tee", "get_secret", [token, key, defaultValue])
    Cordova->>Tee: execute("get_secret", args)
    Tee->>Tee: getPluginIdFromToken(token)
    Tee->>EPM: new EncryptedPreferenceManager(context, pluginId)
    Tee->>EPM: getString(key, defaultValue)
    EPM-->>Tee: decrypted value
    Tee-->>Cordova: success callback with value
    Cordova-->>PC: resolve(value)
    PC-->>Plugin: Promise resolved with value
Loading

Last reviewed commit: a51e038

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile




private Context context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing import for Context

Suggested change
private Context context;
import android.content.Context;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaWebView;

Add these imports after line 16 (after the java.util imports)

Comment on lines +38 to +48
getSecret(token, key, defaultValue = "") {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"get_secret",
[token, key, defaultValue]
);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token parameter is redundant - should use this.uuid like other methods

Suggested change
getSecret(token, key, defaultValue = "") {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"get_secret",
[token, key, defaultValue]
);
});
}
getSecret(key, defaultValue = "") {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"get_secret",
[this.uuid, key, defaultValue]
);
});
}

Comment on lines +51 to +61
setSecret(token, key, value) {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"set_secret",
[token, key, value]
);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token parameter is redundant - should use this.uuid like other methods

Suggested change
setSecret(token, key, value) {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"set_secret",
[token, key, value]
);
});
}
setSecret(key, value) {
return new Promise((resolve, reject) => {
exec(
resolve,
reject,
"Tee",
"set_secret",
[this.uuid, key, value]
);
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant