Registry / auth-security / opencode-antigravity-auth

opencode-antigravity-auth

JSON →
library1.6.0jsnpmunverified

opencode-antigravity-auth v1.6.0 is an OAuth authentication plugin for the OpenCode IDE, providing access to Google Antigravity services including Gemini 3 Pro and Claude 4.6 models. It handles credential management, token refresh, and request signing. Released in 2025, it follows a monthly release cadence with beta releases for testing. Key differentiators are its deep integration with OpenCode's plugin system and support for the latest Google Antigravity API features. Requires Node >=20 and TypeScript ^5 as a peer dependency. Ships bundled TypeScript definitions.

npm install opencode-antigravity-auth
INSTALL
IMPORT
SIG · OPENCODE-ANTIGRAVI
O
opencode-antigravity-auth
auth-securityjavascriptv1.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import antigravityAuth from 'opencode-antigravity-auth'
const antigravityAuth = require('opencode-antigravity-auth')
This package is ESM-only since v1.0. CommonJS require will fail.
configureAuth
import { configureAuth } from 'opencode-antigravity-auth'
import { configureAuth } from 'opencode-antigravity-auth/configure'
configureAuth is a named export from the main module. There is no subpath export.
AuthProvider
import type { AuthProvider } from 'opencode-antigravity-auth'
AuthProvider is a type export. Use 'import type' to avoid bundling issues in TypeScript.
createMiddleware
import { createMiddleware } from 'opencode-antigravity-auth'
import { createMiddleware } from 'opencode-antigravity-auth/middleware'
createMiddleware is re-exported from the main entry. No separate middleware module.

Shows standard OAuth flow: initialize plugin, generate auth URL, exchange code, and make authenticated API request.

import antigravityAuth from 'opencode-antigravity-auth'; // Initialize the auth plugin with required configuration const auth = antigravityAuth({ clientId: process.env.GOOGLE_CLIENT_ID ?? '', clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? '', redirectUri: 'http://localhost:3000/callback', scopes: ['openid', 'email', 'profile'], }); // Generate the authorization URL const authUrl = auth.generateAuthUrl(); console.log('Open the following URL in your browser:', authUrl); // After redirect, exchange the code for tokens const tokens = await auth.exchangeCode('authorization-code-from-query'); console.log('Access token:', tokens.accessToken); // Use the tokens to make authenticated requests const response = await auth.request('/api/gemini', { method: 'POST', body: JSON.stringify({ prompt: 'Hello' }), }); console.log('API response:', await response.json());
Debug
Known issues
breakingSince v1.6.0, the configureAuth function requires an explicit scopes array; previously it defaulted to ['openid']. Scripts relying on the default will fail at runtime.
fix
Pass a scopes array explicitly: configureAuth({ scopes: ['openid', 'email'] })
affects: >=1.6.0
breakingIn v1.6.0, generateAuthUrl now throws if clientId or redirectUri is missing (was previously ignored).
fix
Ensure both clientId and redirectUri are provided in the configuration object.
affects: >=1.6.0
deprecatedThe getToken method is deprecated in v1.6.0; use exchangeCode instead.
fix
Replace getToken(code) with exchangeCode(code).
affects: >=1.6.0
gotchaThe package uses a .mjs extension for ESM. If your project is CJS, you must use dynamic import() or switch to ESM.
fix
Use import() syntax: const antigravityAuth = await import('opencode-antigravity-auth');
affects: >=1.0.0
gotchaUser tokens are stored in ~/.cache/opencode by default. Clearing this cache will log out the user.
fix
To avoid logout, do not delete the cache directory unless intentionally resetting credentials.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/opencode-antigravity-auth/index.mjs not supported.
Trying to require() an ESM-only package in a CommonJS project.
fix
Use dynamic import: const antigravityAuth = await import('opencode-antigravity-auth');
TypeError: auth.generateAuthUrl is not a function
configureAuth was called without clientId or redirectUri, causing generateAuthUrl to not be attached.
fix
Ensure the config object includes both clientId and redirectUri.
Error: Cannot find module 'opencode-antigravity-auth'
The package is not installed or is not in node_modules.
fix
Run npm install opencode-antigravity-auth
TypeError: Cannot destructure property 'accessToken' of 'tokens' as it is undefined.
exchangeCode was called without a valid authorization code, or the code expired.
fix
Verify the authorization code is fresh and passed correctly.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
typescriptoptionalpeer dependency >=5 for type definitions
Agent activity
39 hits · last 30 days
node
36
OpenAI (training)
1
Resources
opencode-antigravity-auth — npm install opencode-antigravity-auth · libregistry