UNPKG

@dataroadinc/setup-auth

Version:

CLI tool and programmatic API for automated OAuth setup across cloud platforms

21 lines (20 loc) 652 B
export function decodeJWT(token) { try { const base64Payload = token.split(".")[1]; const decodedPayload = Buffer.from(base64Payload, "base64").toString("utf-8"); return JSON.parse(decodedPayload); } catch (error) { console.error("Failed to decode JWT:", error); return undefined; } } export function generateRandomSecret() { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; let result = ""; const length = 32; for (let i = 0; i < length; i++) { result += chars.charAt(Math.floor(Math.random() * chars.length)); } return result; }