Abrova
☰ Docs menu · Node.js admin SDK (server)

Admin SDK (server)

View as Markdown

Abrova Auth for your server, with the Firebase Admin SDK's names: setCustomUserClaims, getUser and revokeRefreshTokens. The @abrova/auth-admin package for Node.js, or the same calls as plain HTTPS requests from any language.

For your server only.

The Admin SDK manages your app's users from your own server: their custom claims, their account details and their sessions. It uses the project's server secret, so it never runs in an app or a browser. Apps sign users in with the Abrova Auth SDKs.

Step 1: Installation#

The package comes from Abrova Center. Point the @abrova scope at the Abrova registry in your project's .npmrc:

.npmrcINI
@abrova:registry=https://center.abrova.ir/api/packages/abrova/npm/
bash
npm install @abrova/auth-admin

It needs Node.js 18 or later and has no dependencies.

Step 2: Initialization#

Set three environment variables on your server. You find them in the Console under Project settings:

VariableValue
ABROVA_PROJECT_IDThe project id.
ABROVA_API_KEYThe public API key (ab_live_...).
ABROVA_SERVER_SECRETThe server secret (ab_srv_...). Server only.
ts
import { initAdmin } from '@abrova/auth-admin';

const auth = initAdmin();

You can also pass them in code: initAdmin({ projectId, apiKey, serverSecret }).

setCustomUserClaims#

Replaces all of a user's custom claims. null or {} removes them. See Custom claims for what a claim can hold.

ts
await auth.setCustomUserClaims(userId, { plan: 'pro', teams: ['red'] });

getUser#

Returns the user, with Firebase's UserRecord names:

ts
const user = await auth.getUser(userId);
FieldWhat it is
uidThe user id (ru_...).
email, emailVerifiedThe e-mail address, when the user has one, and whether it is confirmed.
phoneNumberThe phone number of a Telegram sign-in, or null.
displayNameThe name from Apple or Google sign-in, or null.
disabledTrue when the user is disabled in the Console.
providerDataThe linked sign-in methods, for example [{ providerId: "google" }]. Empty for an anonymous user.
metadatacreationTime, lastSignInTime and lastRefreshTime (the last session renewal).
customClaimsThe custom claims, {} when none.
tokensValidAfterTimeThe last time all of the user's sessions were ended, or null.
anonymousTrue for an anonymous user.

revokeRefreshTokens#

Ends every session of the user, on every device: no renewal works any more, so the user signs in again. Access tokens already issued keep working until they expire, at most one hour later.

ts
await auth.revokeRefreshTokens(userId);

Errors#

Every error is an AbrovaAuthAdminError with a code and the HTTP status:

CodeHTTPMeaning
INVALID_CLAIMS400The claims break a rule. The message names the first problem, for example "claims.sub: not an allowed name".
USER_NOT_FOUND404No such user in this project.
UNAUTHENTICATED401Wrong API key or server secret, a key of another project, or an address your project's IP allow-list does not allow.
RATE_LIMITED429Too many calls in a minute. Wait and try again.
NETWORK-Abrova Auth could not be reached.

Without Node.js: the REST API#

Every call is one HTTPS request to https://auth-users.abrova.ir with two headers, x-api-key and x-server-secret:

CallRequest
setCustomUserClaimsPUT /v1/projects/{projectId}/users/{userId}/custom-claims with the body { "claims": { ... } }
getUserGET /v1/projects/{projectId}/users/{userId}
revokeRefreshTokensPOST /v1/projects/{projectId}/users/{userId}/revoke-refresh-tokens
php
// PHP (Laravel)
Http::withHeaders([
    'x-api-key' => env('ABROVA_API_KEY'),
    'x-server-secret' => env('ABROVA_SERVER_SECRET'),
])->put("https://auth-users.abrova.ir/v1/projects/{$projectId}/users/{$userId}/custom-claims", [
    'claims' => ['plan' => 'pro'],
]);

Errors come back as JSON with the same code and a message.

Was this page helpful?
Report a problem

Last updated: 5 Nov 2026