New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@mastra/auth-cloud

Package Overview
Dependencies
Maintainers
7
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.1.4
View campaign page

@mastra/auth-cloud

Mastra Cloud authentication with PKCE OAuth

Source
npmnpm
Version
1.2.1-alpha.0
Version published
Weekly downloads
98
-82.93%
Maintainers
7
Weekly downloads
 
Created
Source

@mastra/auth-cloud

Mastra Cloud authentication provider with PKCE OAuth flow.

Installation

pnpm add @mastra/auth-cloud

Usage

import { Mastra } from '@mastra/core/mastra';
import { MastraCloudAuth } from '@mastra/auth-cloud';

const auth = new MastraCloudAuth({
  projectId: process.env.MASTRA_PROJECT_ID!,
  // Optional: defaults to https://cloud.mastra.ai
  baseUrl: process.env.MASTRA_CLOUD_URL,
  // Optional: defaults to /auth/callback
  redirectPath: '/auth/callback',
});

const mastra = new Mastra({
  server: {
    auth,
  },
});

Configuration

OptionRequiredDefaultDescription
projectIdYes-Project ID from cloud.mastra.ai
baseUrlNohttps://cloud.mastra.aiMastra Cloud base URL
redirectPathNo/auth/callbackOAuth callback path
cookieNameNomastra_sessionSession cookie name

Authentication Flow

This package implements PKCE OAuth flow with Mastra Cloud:

  • User clicks login, redirected to Mastra Cloud with code challenge
  • User authenticates via Mastra Cloud (GitHub OAuth)
  • Mastra Cloud redirects back with authorization code
  • Package exchanges code + verifier for session token
  • Session token stored in HttpOnly cookie

API

MastraCloudAuth

The main authentication provider class implementing MastraAuthProvider.

Methods

  • getLoginUrl(state?) - Get OAuth login URL with PKCE
  • handleCallback(code, verifier) - Exchange code for session
  • verifyToken(token) - Verify session and get user with role
  • refreshSession(token) - Refresh expiring session
  • logout(token) - Invalidate session

License

Apache-2.0

FAQs

Package last updated on 25 Jun 2026

Related posts