Pebble: Implement getAccountToken for paid watchfaces/apps

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent 3528ab725c
commit 5a6bdace66
2 changed files with 10 additions and 1 deletions
@@ -222,7 +222,7 @@ function gbPebble() {
}
this.getAccountToken = function() {
return '';
return GBjs.getAccountToken();
}
this.getWatchToken = function() {
@@ -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/