0.3.1 • Published 2 years ago
@codehelios/verify-tokenid v0.3.1
Verify TokenId
Lightweight zero dependency library to verify Firebase ID Token in Cloudflare Workers.
Usage/Examples
Verify ID Token
import { verifyTokenId } from "@codehelios/verify-tokenid";
const { isValid, decoded, error } = await verifyTokenId(tokenId, "https://securetoken.google.com/<projectId>", "<projectId>");
API Reference
Verify ID Token
Verifies Firebase ID Token and returns object
containing { isValid, decoded, error }
verifyTokenId(token, issure, audience)
Arguments
Parameter | Type | Description |
---|---|---|
token | string | Required. Firebase ID Token |
issure | string | Required. Must be "https://securetoken.google.com/", where is the same project ID used for aud above. |
audience | string | Required. Must be your Firebase project ID, the unique identifier for your Firebase project, which can be found in the URL of that project's console. |
Returns
object
containing { isValid, decoded, error }
Property | Type | Description |
---|---|---|
isValid | boolen | Indicates whether given Firebase ID Token is valid or not |
decoded | object or null | If ID Token is valid this will be decoded JWT Object { header, payload } |
error | string or null | If isValid is false then this will be error message saying why isValid is false otherwise null |
License
Authors