Skip to content

Commit

Permalink
Fix Token expiry bug for issue #461.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jan 8, 2023
1 parent 04eff0e commit 7731b93
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Firebase Arduino Client Library for ESP8266 and ESP32",
"version": "4.3.1",
"version": "4.3.2",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"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=Firebase Arduino Client Library for ESP8266 and ESP32

version=4.3.1
version=4.3.2

author=Mobizt

Expand Down
3 changes: 1 addition & 2 deletions src/FB_Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico (RP2040)
*
* Created January 7, 2023
* Created January 8, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1688,7 +1688,6 @@ namespace TimeHelper
uint32_t &tm = *mb_ts;

#if defined(ESP8266) || defined(ESP32) || defined(PICO_RP2040)
if (tm < ESP_DEFAULT_TS)
tm = time(nullptr);
#else
tm = millis() / 1000;
Expand Down
14 changes: 10 additions & 4 deletions src/Firebase.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The Firebase class, Firebase.cpp v1.2.3
* The Firebase class, Firebase.cpp v1.2.4
*
* Created January 7, 2023
* Created January 8, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -126,15 +126,21 @@ struct token_info_t Firebase_ESP_Client::authTokenInfo()
bool Firebase_ESP_Client::ready()
{
#if defined(ESP32) || defined(ESP8266)
// We need to close all data object TCP sessions when token was expired.
// Stop the session only for ESPs to free the memory when token
// expired (actually nearly expired) as the Signer needs memory
// to open another secure TCP session to request new orrefresh token.
// We don't stop session to free memory on other devices e,g, Pico as it uses
// BearSSL engine that required less memory then it has enough free memory
//to do other things.
if (Signer.isExpired())
{
if (Signer.config)
{
for (size_t id = 0; id < Signer.config->internal.sessions.size(); id++)
{
FirebaseData *fbdo = addrTo<FirebaseData *>(Signer.config->internal.sessions[id]);
if (fbdo && !fbdo->tcpClient.reserved)
// non-stream used session will stop
if (fbdo && !fbdo->tcpClient.reserved && fbdo->session.con_mode != fb_esp_con_mode_rtdb_stream)
fbdo->closeSession();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Firebase.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

/**
* The Firebase class, Firebase.h v1.2.3
* The Firebase class, Firebase.h v1.2.4
*
* Created January 7, 2023
* Created January 8, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
10 changes: 4 additions & 6 deletions src/Firebase_ESP_Client.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "4.3.1"
#define FIREBASE_CLIENT_VERSION "4.3.2"
#endif

/**
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v4.3.1
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v4.3.2
*
* This library supports Espressif ESP8266 and ESP32 MCUs and Raspberry Pi RP2040 Pico MCUs.
*
* Created January 7, 2023
* Created January 8, 2023
*
* Updates:
* - Bugs fixed.
* - Add support RP2040 Pico.
* - Add runStream for RTDB and runDeployTasks for Functions.
* - Fix Token expiry bug for issue #461 which introduced in v4.3.0.
*
*
* This work is a part of Firebase ESP Client library
Expand Down

0 comments on commit 7731b93

Please sign in to comment.