]> git.earman.xyz Git - sensor-watch.git/commitdiff
Allow to pass secrets to totp_face through a separate (ignored) header.
authorMathias Kende <mathias@kende.fr>
Fri, 29 Aug 2025 20:05:13 +0000 (22:05 +0200)
committerMathias Kende <mathias@kende.fr>
Fri, 29 Aug 2025 20:05:19 +0000 (22:05 +0200)
That header (`totp_face.secrets.h`) is listed in the .gitignore file for that directory, so that there is limited risk to commit it to GitHub by mistake (at least less than when the secrets are directly listed in `totp_face.c`). And this is also easier to use than totp_lfs_face (at least until secrets can be sent to that face over IR).

watch-faces/complication/.gitignore [new file with mode: 0644]
watch-faces/complication/totp_face.c
watch-faces/complication/totp_face.h

diff --git a/watch-faces/complication/.gitignore b/watch-faces/complication/.gitignore
new file mode 100644 (file)
index 0000000..c33c021
--- /dev/null
@@ -0,0 +1 @@
+totp_face.secrets.h
index b45c62f6f70e2954c6f58a137bd10d025f779db6..d8ec461ba8dfd3f7a21d19bcf980562b27533080 100644 (file)
@@ -64,10 +64,14 @@ typedef struct {
 ////////////////////////////////////////////////////////////////////////////////
 // Enter your TOTP key data below
 
+#if __has_include("totp_face.secrets.h")
+#include "totp_face.secrets.h"
+#else
 static totp_t credentials[] = {
     CREDENTIAL(2F, "JBSWY3DPEHPK3PXP", SHA1, 30),
     CREDENTIAL(AC, "JBSWY3DPEHPK3PXP", SHA1, 30),
 };
+#endif
 
 // END OF KEY DATA.
 ////////////////////////////////////////////////////////////////////////////////
index 0dc1b8e6e2aeac129e2bce65e26ca037e249653f..8628ff83a04cde59d9704bb30276834986cef946 100644 (file)
  *      o `algorithm` is one of the supported hashing algorithms listed above.
  *      o `timestep` is how often the TOTP refreshes in seconds. This is usually
  *        30 seconds.
+ *  o Alternatively, place the `credentials` variable as-is in a file named
+ *    `totp_face.secrets.h` in this directory, and it will be included instead.
+ *    This lowers the risk of commiting your OTP secrets to GitHub as that file
+ *    is listed in the .gitignore file.
  *
  * If you have more than one secret key, press ALARM to cycle through them.
  * Press LIGHT to cycle in the other direction or keep it pressed longer to