diff --git a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js index 679eeef30e..25f23693c6 100644 --- a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js +++ b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js @@ -222,7 +222,7 @@ function gbPebble() { } this.getAccountToken = function() { - return ''; + return GBjs.getAccountToken(); } this.getWatchToken = function() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/JSInterface.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/JSInterface.java index 024436a23b..b03c210650 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/JSInterface.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/JSInterface.java @@ -40,6 +40,7 @@ import java.util.UUID; import androidx.annotation.NonNull; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.util.CheckSums; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils; @@ -211,6 +212,14 @@ public class JSInterface { } } + @JavascriptInterface + public String getAccountToken() { + //specification says: A unique account token that is associated with the Pebble account of the current user. + //we don't have an account, so we use the device's mac address instead + //this allows purchasing / using purchased watchfaces using kiezelpay + return GB.hexdump(CheckSums.md5(this.device.getAddress().getBytes())); + } + @JavascriptInterface public String getWatchToken() { //specification says: A string that is guaranteed to be identical for each Pebble device for the same app across different mobile devices. The token is unique to your app and cannot be used to track Pebble devices across applications. see https://developer.pebble.com/docs/js/Pebble/