{"id":18837,"library":"supaapps-auth","title":"supaapps-auth","description":"Authentication library for SupaApps projects. Current version 3.2.2, providing token management, OAuth login flows (Google), and token validation. It uses a singleton pattern via AuthManager and supports ESM imports with TypeScript types included. Differentiators include simple API with login URI generation, access token decoding, and Bearer token validation. Release cadence is not specified but likely follows SupaApps updates.","status":"active","version":"3.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/supaapps/supaapps-auth","tags":["javascript","typescript"],"install":[{"cmd":"npm install supaapps-auth","lang":"bash","label":"npm"},{"cmd":"yarn add supaapps-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add supaapps-auth","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export, not default. Also avoid CommonJS require as package is ESM-only.","wrong":"import AuthManager from 'supaapps-auth'","symbol":"AuthManager","correct":"import { AuthManager } from 'supaapps-auth'"},{"note":"TypeScript type import for type-only usage.","symbol":"AuthManager (type)","correct":"import type { AuthManager } from 'supaapps-auth'"},{"note":"Optional renaming to avoid conflicts.","symbol":"AuthManager (namespace)","correct":"import { AuthManager as AM } from 'supaapps-auth'"}],"quickstart":{"code":"import { AuthManager } from 'supaapps-auth';\n\nconst authManager = new AuthManager(\n  'https://supaapps-auth-api.testing.sacl.io/',\n  'root',\n  'http://localhost:3001/exchange',\n  () => { console.log('redirect to login'); }\n);\n\n// Check if user must be logged in\nauthManager.mustBeLoggedIn().then((isLoggedIn) => {\n  if (isLoggedIn) {\n    // Proceed\n  } else {\n    authManager.getLoginWithGoogleUri().then((uri) => {\n      window.location.href = uri;\n    });\n  }\n});\n\n// Logout\nauthManager.logout().then(() => {\n  console.log('Logged out');\n});","lang":"typescript","description":"Initializes AuthManager with API URL, tenant, redirect URI and redirect callback; checks login status, gets Google login URI, and logs out."},"warnings":[{"fix":"Ensure token is stored via setAccessToken() or login flow.","message":"mustBeLoggedIn() may return false even if token is valid if token is not in local storage","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Use AuthManager.getInstance() after initial construction, or consistently use constructor without getInstance.","message":"new AuthManager() constructs a new instance, but getInstance() returns a singleton. Mixing patterns may cause multiple API calls.","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Use AuthManager.validateToken() as shown, but monitor for replacement.","message":"validateToken() may be deprecated in future versions; check docs","severity":"deprecated","affected_versions":">=3.2"},{"fix":"Assign window.location.href to the URI, or use an anchor tag.","message":"getLoginWithGoogleUri() returns a URI, but does not automatically redirect; developer must handle navigation.","severity":"gotcha","affected_versions":">=3.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install supaapps-auth and ensure tsconfig.json includes 'node_modules/@types' or the package's types.","cause":"Package not installed or TypeScript unable to resolve types (though types are shipped).","error":"Cannot find module 'supaapps-auth' or its corresponding type declarations."},{"fix":"Use import { AuthManager } from 'supaapps-auth' instead of import AuthManager from 'supaapps-auth'.","cause":"Using default import instead of named import.","error":"TypeError: supaapps_auth_1.AuthManager is not a constructor"},{"fix":"Ensure AuthManager is instantiated or getInstance() is called after construction.","cause":"Calling mustBeLoggedIn on undefined or wrong object (e.g., using getInstance() before constructor).","error":"Error: authManager.mustBeLoggedIn is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}