UNPKG

@react-native-ohos/realm

Version:

Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores

68 lines (67 loc) 1.87 kB
import type { binding } from "../binding"; /** * The representation of an API-key stored in the service. */ export type ApiKey = { /** * The internal identifier of the key. */ _id: string; /** * A name for the key. */ name: string; /** * When disabled, the key cannot authenticate. */ disabled: boolean; }; /** * The representation of an API-key when returned from the server, just after creation. */ export type SecretApiKey = ApiKey & { /** * The secret part of the key. */ key: string; }; /** * Authentication provider where users identify using an API-key. */ export declare class ApiKeyAuth { /** @internal */ private user; /** @internal */ private internal; /** @internal */ constructor(user: binding.User, internal: binding.UserApiKeyProviderClient); /** * Creates an API key that can be used to authenticate as the current user. * @param keyName the name of the API key to be created. */ create(keyName: string): Promise<SecretApiKey>; /** * Fetches an API key associated with the current user. * @param keyId the id of the API key to fetch. */ fetch(keyId: string): Promise<ApiKey>; /** * Fetches the API keys associated with the current user. */ fetchAll(): Promise<ApiKey[]>; /** * Deletes an API key associated with the current user. * @param keyId the ID of the API key to delete */ delete(keyId: string): Promise<void>; /** * Enables an API key associated with the current user. * @param keyId the ID of the API key to enable */ enable(keyId: string): Promise<void>; /** * Disable an API key associated with the current user. * @param keyId the ID of the API key to disable */ disable(keyId: string): Promise<void>; }