Skip to content

Commit

Permalink
Merge pull request #2 from qube-ai/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
mys10gan authored Dec 7, 2022
2 parents 2fe848d + 08551bd commit 249076a
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Test (check if code compiles)

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v2

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install dependencies
working-directory: ./examples/simple
run: pio pkg install

- name: Build
working-directory: ./examples/simple
run: pio run
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release Build

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v2

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install dependencies
working-directory: ./examples/simple
run: pio pkg install

- name: Build
working-directory: ./examples/simple
run: pio run

- name: create env variable for lib version from library.json
id: lib_version
run: echo "::set-output name=version::$(cat library.json | grep "version" | cut -d '"' -f 4)"

- name: Create Github Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: "v${{ steps.lib_version.outputs.version }}"
token: ${{ secrets.TOKEN_GITHUB }}
name: "v${{ steps.lib_version.outputs.version }}"
body: "This is a production build for the v${{ steps.lib_version.outputs.version }}. Changelog will be added in future versions."
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ void loop()

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
This project is licensed under the UnLicense - see the [LICENSE](LICENSE) file for details

## Configuration

- Enable debug mode by defining `AsymJwt_Logging` before including the library.
- Enable debug mode by defining `ASYMJWT_DEBUG` before including the library.

```cpp
#define AsymJwt_Logging 1
#define ASYMJWT_DEBUG 1

#include <AsymJwt.h>
```
Expand Down
7 changes: 7 additions & 0 deletions examples/simple/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[env:release]
platform = espressif8266
board = esp12e
framework = arduino
lib_deps =
; https://github.com/qube-ai/tiny-webthing.git
file://../../
24 changes: 24 additions & 0 deletions examples/simple/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <Arduino.h>
#include <AsymJwt.h>


void setup()
{
Serial.begin(9600);
Serial.println("Reading private ket....");
while (!AsymJWT::readPrivKey("/private-key.der"))
{
Serial.println("Failed to read private key. Retrying in 2 seconds");
delay(2000);
}
}


void loop()
{
time_t iat = time(nullptr);
String payload = "{\"iat\":" + String(iat) + ",\"exp\":" + String(iat + 300) + ",\"thing_id\":\"" + "THING_ID" + "\"}";
Serial.println(AsymJWT::generateJwt(payload));
delay(200000);
Serial.println("Refreshing JWT.");
}
9 changes: 7 additions & 2 deletions include/AsymJwt.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
ifdef AsymJwt_Logging
#ifdef ASYMJWT_DEBUG
#define AsymJwt_Log(...) Serial.print(__VA_ARGS__)
#define AsymJwt_Logln(...) Serial.println(__VA_ARGS__)
else
#else
#define AsymJwt_Log(...) (void)0
#define AsymJwt_Logln(...) (void)0
#endif

#include <Arduino.h>

#ifndef AsymJwt_h
#define AsymJwt_h


#include "LittleFS.h"
#include "WiFiClientSecureBearSSL.h"

#include "crypto/make_jwt.h"
#include "crypto/nn.h"
#include "crypto/ecc.h"
Expand Down
2 changes: 0 additions & 2 deletions src/AsymJwt.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "AsymJwt.h"

#include "LittleFS.h"
#include "WiFiClientSecureBearSSL.h"

NN_DIGIT priv_key[9];

Expand Down

0 comments on commit 249076a

Please sign in to comment.