Utilizing Firebase SDK to verify jsonwebtoken

Currently, I am utilizing jsonwebtoken on the server using node to authenticate client requests (specifically with firebase 2.x sdks):

const jwt = require('jsonwebtoken')
jwt.verify(token, <firebase_secret>, (err, decoded) => { })

Up until now, this method has worked flawlessly with requests coming from both browser firebase javascript 2.x and ios firebase 2.x.

However, upon upgrading our ios sdk to firebase 3.x, validation of the token fails with a specific error:

[JsonWebTokenError: jwt malformed] name: 'JsonWebTokenError', message: 'jwt malformed'
.

My objective moving forward is as follows:

  • To continue using browser firebase 2.x
  • To incorporate ios firebase 3.x
  • To still support node firebase 2.x

The question remains - Is there a way to configure the jwt.verify() function to successfully handle tokens originating from both browser 2.x and ios 3.x?

Answer №1

It turns out that there were changes in token signing algorithms and private keys between Firebase SDKs versions 2.x and 3.x.

  • The Node Firebase SDK for version 2.x is known as firebase-server.
  • While the Node Firebase SDK for version 3.x goes by the name firebase-admin.

To solve this issue, I decided to incorporate both libraries on the node server. Clients using version 2.x would send tokens with one key, while clients using version 3.x would send tokens with another key.

On the server-side, we can then decode with either the firebase-server library or the firebase-admin library depending on the type of token received. This approach allows us to update the iOS SDK without requiring simultaneous updates to the web SDK.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Design a circular progress bar with a cut-off at the bottom

Does anyone have suggestions on how to create a circular progress bar with cropping at the bottom, similar to this example: PROGRESS BAR? I've been searching for a component like this but haven't had any luck. Any ideas, especially utilizing Mate ...

Utilizing the zIndex property on a map label does not produce any impact when combined with a GeoJSON layer

Utilizing the Google map label tool, I am trying to showcase certain property from GeoJSON data on a GeoJSON layer. However, the issue arises as the layer has a dark color and the label is appearing blurry behind the GeoJSON data layer. Despite attempting ...

Incorporating Paged.JS functionality into a React/JS web application

My attempt to showcase my html page using paged.js in a react project has hit a snag. The html loads perfectly when accessed from local host (not via npm start, but the live server extension on vscode). However, following the steps outlined on this website ...

Actility's LoraWan platform integrated with Node-Red

I am currently working on learning how to implement an HTTP GET request for the Actility platform in Node-RED. However, I keep encountering an error 401 indicating that the authorization bearer is missing. This is how my setup looks: https://i.sstatic.ne ...

Steps for organizing a list based on the number of clicks

I've created an HTML list with images of political party logos. Each logo is a grid item that can be clicked on. I want to sort the list based on the number of clicks each logo receives, essentially ranking them by popularity. However, I'm not su ...

How to implement PayPal integration in PHP

I am currently working on integrating the paypal payment system into a website dedicated to pet adoption. Initially, I had a basic code structure that was functional. However, after making some modifications and additions to the code, it no longer redirect ...

Show various error messages depending on the type of error detected

When pulling data from an API, my goal is to handle errors appropriately by displaying custom error messages based on the type of error that occurs. If the response is not okay, I want to throw an error and show its message. However, if there is a network ...

Using JQuery to adjust the image width to 100% when the height is greater than the width

Currently, I am working on developing a custom WordPress theme and here is the code snippet that I have been using: <div class="post-thumb"> <?php echo get_the_post_thumbnail(); ?> </div> I am facing an issue where I need to adjust the ...

Accessing data attributes using jQuery and the class selector

I'm looking for a way to trigger an onClick event for an entire class of elements and access their individual data attributes within the function. Typically, I would use the following method: $(".classy").click(function(){ console.log("Replace th ...

Is there a way to extract all the class names from a JavaScript file?

I am currently working on developing a code to showcase all the public properties of a class that are available in a JavaScript file. As of now, the user has to manually input the name of the class in a text box. However, my goal is to enhance user experie ...

I am facing difficulty in retrieving a unique dynamic div id using the useRef ReactJS hook, as it keeps returning the same id repeatedly

When using the useRef Reactjs hook, I encountered an issue where it returned the same id repeatedly instead of generating a dynamic div id. I need this functionality to map buttons and div ids in order to create a flexible accordion. The goal is to displ ...

Tips for locating the index of a substring within a string with varying line endings using Typescript

I am faced with the task of comparing two strings together. abc\r\ndef c\nde My goal is to determine the index of string 2 within string 1. Using the indexOf() method is not an option due to different line endings, so I require an altern ...

Uploading files with Vue.js Element-UI and axios triggers unwanted page refresh

I am utilizing the element-ui file upload component() to manage the frontend of image uploading. All functionalities work flawlessly (file is successfully sent to the server, etc). However, for some reason, after the axios's successful response code r ...

Tallying discarded objects post removal from drop zone

Is there a way to accurately count dropped items within a dropped area? I have created an example that seems to be working fine but with one minor issue. When I begin removing items, the count does not include the first item and only starts decreasing afte ...

Select a division and retrieve the identification of a different division

I am looking to trigger an event by clicking on one element and extracting the ID from a separate, unrelated div. Here is my attempt: $(".map_flag").on("click",function(){ var selectedID = ($(this).attr("data_modal")); $("#" + selectedID).fade ...

Node.js POST request only executes successfully on the second attempt

I am facing a peculiar issue where upon submitting a form, it redirects to the form action URL and then displays a blank page. However, upon reloading the page, the data is displayed. index.jade - http://172.18.0.60:3000/ form#command(action='runc ...

Issue encountered when attempting to sign up a user with passport.js

I encounter a "Bad Request" message when attempting to create a new user using Postman with the following content: { "username": "username", "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="07626a666e6b47626a66 ...

MiniCssExtractPlugin is failing to generate the CSS file as expected

Having issues with CSS Modules not working while implementing server side rendering with React/Node. Recently added mini-css-extract-plugin to separate CSS from JS, but the plugin is not generating a CSS file in the public directory. /package.json { . ...

How do callback functions in Javascript interact with variables outside of their scope?

Greetings to all. I am facing an issue regarding the 'callback function - scope of variable', My intention is to utilize the 'i in for loop' with the 'callback function User_UidSearch', however, I am unable to implement it. ...

What is the best way to retrieve a return string from an external program using XPCOM in Firefox?

Is there a way to execute an external program in XPCOM and retrieve the actual return string from it, instead of just the return code? I have researched nsICommandLine, nsICommandLineHandler, nsICommandLineRunner, and nsIProcess but it seems like none of ...