Skip to content

Commit

Permalink
Major bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Apr 13, 2024
1 parent 7e8efe8 commit 629a85e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 58 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,14 @@ For example:
`Database.get(<AsyncClientClass>, <path>, <options>, <AsyncResultCallback>);`
From source 1, the async result (`<AsyncResult>`) shall be defined globally to use in async application because of the static data is needed for use while running the async task.
From source 1, the async result (`<AsyncResult>`) shall be defined globally to use in async application because of the static data buffer is needed for use while running the async task.
From source 2, the async client (`AsyncClientClass`) shall be defined globally to use in async application too to make sure the instance of async result was existed or valid while running the async task.
The async result from source 2 can be accessed from the async result callback.
> [!NOTE]
> The async client object used in authentication task shoul be defined globally as it is async task.
> The async client object used in authentication task shoul be defined globally as it runs asynchronously and requires the static data buffer to store the result.
The aync result provides two types of information, `app events` and `result data`.
Expand Down Expand Up @@ -610,7 +610,7 @@ The parameters for the [CustomAuth](examples/App/AppInitialization/CustomAuth/Cu
CustomAuth::CustomAuth(<TimeStatusCallback>, <api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>);
```

`<TimeStatusCallback>` The time status callback that provide the UNIX timestamp value used for JWT token signing.
`<TimeStatusCallback>` The time status callback that provides the UNIX timestamp value used for JWT token signing.

`<api_key>` The web API key of project.

Expand All @@ -620,11 +620,11 @@ CustomAuth::CustomAuth(<TimeStatusCallback>, <api_key>, <client_email>, <project

`<private_key>` The service account private key.

`<user_id>`The user ID.
`<user_id>` The user ID.

`<scope>` The OAuth scopes.

`<claims>`The OAuth claims.
`<claims>` The OAuth claims.

`<expire>`The expiry period in seconds (less than 3600), 3300 is the default value.

Expand Down Expand Up @@ -724,7 +724,7 @@ AccessToken::AccessToken(<auth_token>, <expire_in_seconds>, <refresh_token>, <cl

`<auth_token>` Auth token from OAuthe2.0 auth.

`<expire_in_seconds>` Expire period in seconds
`<expire_in_seconds>` Expire period in seconds

`<refresh_token>` Refresh token.

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.0.16",
"version": "1.1.0",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.0.16
version=1.1.0

author=Mobizt

Expand Down
6 changes: 3 additions & 3 deletions src/FirebaseClient.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created April 12, 2024
* Created April 13, 2024
*
* The MIT License (MIT)
* Copyright (c) 2024 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -30,7 +30,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.0.16"
#define FIREBASE_CLIENT_VERSION "1.1.0"

#include <Arduino.h>
#include "./core/FirebaseApp.h"
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace firebase
#endif
app.auth_data.app_token.authenticated = true;

resetTimer(app, false, 3600);
resetTimer(app, false, FIREBASE_DEFAULT_TOKEN_TTL);
}
else if (app.auth_data.user_auth.auth_data_type == user_auth_data_id_token)
{
Expand Down
38 changes: 20 additions & 18 deletions src/core/AuthConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created April 6, 2024
* Created April 13, 2024
*
* The MIT License (MIT)
* Copyright (c) 2024 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -30,6 +30,8 @@

#include "./core/AsyncResult/AsyncResult.h"

#define FIREBASE_DEFAULT_TOKEN_TTL 3300

namespace sa_ns
{
enum data_item_type_t
Expand Down Expand Up @@ -291,15 +293,15 @@ namespace firebase
for (size_t i = 0; i < sa_ns::max_type; i++)
val[i].remove(0, val[i].length());
timestatus_cb = NULL;
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
step = jwt_step_begin;
}

protected:
String val[sa_ns::max_type];
jwt_step step = jwt_step_begin;
TimeStatusCallback timestatus_cb = NULL;
size_t expire = 3300;
size_t expire = FIREBASE_DEFAULT_TOKEN_TTL;
};
#endif

Expand Down Expand Up @@ -332,7 +334,7 @@ namespace firebase
struct user_data
{
String val[user_ns::max_type];
size_t expire = 3300;
size_t expire = FIREBASE_DEFAULT_TOKEN_TTL;

public:
user_data() {}
Expand All @@ -347,15 +349,15 @@ namespace firebase
{
for (size_t i = 0; i < user_ns::max_type; i++)
val[i].remove(0, val[i].length());
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
}
};

#if defined(ENABLE_ID_TOKEN)
struct id_token_data
{
String val[id_tk_ns::max_type];
size_t expire = 3300;
size_t expire = FIREBASE_DEFAULT_TOKEN_TTL;

public:
id_token_data() {}
Expand All @@ -370,7 +372,7 @@ namespace firebase
{
for (size_t i = 0; i < id_tk_ns::max_type; i++)
val[i].remove(0, val[i].length());
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
}
};
#endif
Expand All @@ -379,7 +381,7 @@ namespace firebase
struct access_token_data
{
String val[access_tk_ns::max_type];
size_t expire = 3300;
size_t expire = FIREBASE_DEFAULT_TOKEN_TTL;
TimeStatusCallback timestatus_cb = NULL;

public:
Expand All @@ -396,7 +398,7 @@ namespace firebase
{
for (size_t i = 0; i < access_tk_ns::max_type; i++)
val[i].remove(0, val[i].length());
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
timestatus_cb = NULL;
}
};
Expand All @@ -406,7 +408,7 @@ namespace firebase
struct custom_token_data
{
String val[cust_tk_ns::max_type];
size_t expire = 3300;
size_t expire = FIREBASE_DEFAULT_TOKEN_TTL;
TimeStatusCallback timestatus_cb = NULL;

public:
Expand All @@ -421,7 +423,7 @@ namespace firebase
void clear()
{
val[cust_tk_ns::token].remove(0, val[cust_tk_ns::token].length());
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
timestatus_cb = NULL;
}
};
Expand Down Expand Up @@ -787,7 +789,7 @@ namespace firebase
friend class FirebaseApp;

public:
UserAuth(const String &api_key, const String &email, const String &password, size_t expire = 3300)
UserAuth(const String &api_key, const String &email, const String &password, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
{
data.clear();
data.user.val[user_ns::api_key] = api_key;
Expand Down Expand Up @@ -849,7 +851,7 @@ namespace firebase
friend class FirebaseApp;

public:
ServiceAuth(TimeStatusCallback timeCb, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = 3300)
ServiceAuth(TimeStatusCallback timeCb, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
{
data.clear();
data.sa.val[sa_ns::cm] = clientEmail;
Expand Down Expand Up @@ -896,7 +898,7 @@ namespace firebase
friend class FirebaseApp;

public:
CustomAuth(TimeStatusCallback timeCb, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &scope = "", const String &claims = "", size_t expire = 3300)
CustomAuth(TimeStatusCallback timeCb, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &scope = "", const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
{
data.clear();
data.sa.val[sa_ns::cm] = clientEmail;
Expand Down Expand Up @@ -997,7 +999,7 @@ namespace firebase
friend class FirebaseApp;

public:
IDToken(const String &api_key, const String &token, size_t expire = 3300, const String &refresh = "")
IDToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "")
{
this->data.clear();
this->data.user.val[user_ns::api_key] = api_key;
Expand Down Expand Up @@ -1063,7 +1065,7 @@ namespace firebase
friend class FirebaseApp;

public:
AccessToken(const String &token, size_t expire = 3300, const String &refresh = "", const String &client_id = "", const String &client_secret = "")
AccessToken(const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "", const String &client_id = "", const String &client_secret = "")
{
this->data.clear();
this->data.access_token.val[access_tk_ns::token] = token;
Expand Down Expand Up @@ -1130,7 +1132,7 @@ namespace firebase
friend class FirebaseApp;

public:
CustomToken(const String &api_key, const String &token, size_t expire = 3300)
CustomToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
{
this->data.clear();
this->data.custom_token.val[cust_tk_ns::token] = token;
Expand Down Expand Up @@ -1280,7 +1282,7 @@ namespace firebase
{
for (size_t i = 0; i < app_tk_ns::max_type; i++)
val[i].remove(0, val[i].length());
expire = 3300;
expire = FIREBASE_DEFAULT_TOKEN_TTL;
authenticated = false;
auth_type = auth_unknown_token;
auth_data_type = user_auth_data_undefined;
Expand Down
Loading

0 comments on commit 629a85e

Please sign in to comment.