Pyric
Navigate

API reference

pyric-admin/auth

10 published symbols from pyric-admin

Generated from the TypeScript declarations shipped at this import path.

Interfaces

Auth

Sandbox Auth interface intentionally limited to implemented behavior.

Indexable

[key: string]: unknown

Properties

PropertyModifierType
appreadonlySandboxAdminApp

Methods

createCustomToken()
createCustomToken(uid: string, developerClaims?: object): Promise<string>;
Parameters
ParameterType
uidstring
developerClaims?object
Returns

Promise<string>

createUser()
createUser(properties: CreateRequest): Promise<UserRecord>;
Parameters
ParameterType
propertiesCreateRequest
Returns

Promise<UserRecord>

deleteUser()
deleteUser(uid: string): Promise<void>;
Parameters
ParameterType
uidstring
Returns

Promise<void>

getUser()
getUser(uid: string): Promise<UserRecord>;
Parameters
ParameterType
uidstring
Returns

Promise<UserRecord>

getUserByEmail()
getUserByEmail(email: string): Promise<UserRecord>;
Parameters
ParameterType
emailstring
Returns

Promise<UserRecord>

listUsers()
listUsers(maxResults?: number, pageToken?: string): Promise<ListUsersResult>;
Parameters
ParameterType
maxResults?number
pageToken?string
Returns

Promise<ListUsersResult>

setCustomUserClaims()
setCustomUserClaims(uid: string, customUserClaims: object): Promise<void>;
Parameters
ParameterType
uidstring
customUserClaimsobject
Returns

Promise<void>

updateUser()
updateUser(uid: string, properties: UpdateRequest): Promise<UserRecord>;
Parameters
ParameterType
uidstring
propertiesUpdateRequest
Returns

Promise<UserRecord>

verifyIdToken()
verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
Parameters
ParameterType
idTokenstring
checkRevoked?boolean
Returns

Promise<DecodedIdToken>


CreateRequest

Properties

PropertyType
disabled?boolean
displayName?string
email?string
emailVerified?boolean
password?string
phoneNumber?string
photoURL?string
uid?string

DecodedIdToken

Extends

  • Record<string, unknown>

Indexable

[key: string]: unknown

Properties

PropertyType
audstring
auth_timenumber
expnumber
firebase{ identities: Record<string, unknown>; sign_in_provider: string; }
firebase.identitiesRecord<string, unknown>
firebase.sign_in_providerstring
iatnumber
issstring
substring
uidstring

ListUsersResult

Properties

PropertyType
pageToken?string
usersUserRecord[]

UpdateRequest

Extends

Properties

PropertyType
disabled?boolean
displayName?string
email?string
emailVerified?boolean
multiFactor?unknown
password?string
phoneNumber?string
photoURL?string
providersToUnlink?unknown
providerToLink?unknown

UserInfo

Properties

PropertyType
displayName?string
email?string
phoneNumber?string
photoURL?string
providerIdstring
uidstring

Methods

toJSON()
toJSON(): Record<string, unknown>;
Returns

Record<string, unknown>


UserMetadata

Properties

PropertyType
creationTimestring
lastSignInTimestring

Methods

toJSON()
toJSON(): Record<string, unknown>;
Returns

Record<string, unknown>


UserRecord

Properties

PropertyModifierType
customClaims?readonlyRecord<string, unknown>
disabledreadonlyboolean
displayName?readonlystring
email?readonlystring
emailVerifiedreadonlyboolean
metadatareadonlyUserMetadata
phoneNumber?readonlystring
photoURL?readonlystring
providerDatareadonlyUserInfo[]
tenantIdreadonlystring
uidreadonlystring

Methods

toJSON()
toJSON(): Record<string, unknown>;
Returns

Record<string, unknown>

Variables

SANDBOX_TOKEN_PREFIX

const SANDBOX_TOKEN_PREFIX: "pyric-sandbox-custom" = "pyric-sandbox-custom";

Token format minted by createCustomToken and parsed by verifyIdToken. Exported as a constant so tests can lock the shape.

Layout: pyric-sandbox-custom:${uid}:${jsonClaims}

  • The prefix lets verifyIdToken reject foreign tokens with a clear “not a sandbox token” error rather than NaN’ing out.
  • uid is colon-free per the auto-uid format above.
  • jsonClaims is the JSON-stringified developer claims (or {} when none were provided). Round-trips losslessly through JSON.parse.

NOT a JWT. NOT signed. Do not use this token format to talk to any real Firebase service — it only round-trips through this same sandbox backend.

Functions

getAuth()

function getAuth(app?: SandboxAdminApp): Auth;

Return an Auth handle for the given app — or for the DEFAULT app when called with no argument (mirrors firebase-admin’s no-arg getAuth(): resolves '[DEFAULT]' through pyric-admin/app’s registry and throws app/no-app when nothing has been initialized). Local sandboxes use the in-memory store; remote sandboxes relay to the browser-hosted worker.

Parameters

ParameterType
app?SandboxAdminApp

Returns

Auth

Example

import { initializeApp } from 'pyric-admin/app';
import { initializeSandbox } from 'pyric/sandbox';
import { getAuth } from 'pyric-admin/auth';

const sandbox = initializeSandbox();
const app = initializeApp({ sandbox });
const auth = getAuth(app);

const user = await auth.createUser({ uid: 'alice', email: 'a@e.com' });
const token = await auth.createCustomToken(user.uid, { role: 'admin' });
const decoded = await auth.verifyIdToken(token);
console.log(decoded.uid, decoded.role); // 'alice' 'admin'