Security Rules for Cloud Firestore and Cloud Storage.
Functions
| Function | Description |
|---|---|
| getSecurityRules(app) | Gets the SecurityRules service for the default app or a given app.admin.securityRules() can be called with no arguments to access the default app's SecurityRules service, or as admin.securityRules(app) to access the SecurityRules service associated with a specific app. |
Classes
| Class | Description |
|---|---|
| FirebaseSecurityRulesError | Firebase Security Rules error code structure. This extends FirebaseError. |
| Ruleset | A set of Firebase security rules. |
| RulesetMetadataList | A page of ruleset metadata. |
| SecurityRules | The Firebase SecurityRules service interface. |
Interfaces
| Interface | Description |
|---|---|
| RulesetMetadata | Required metadata associated with a ruleset. |
| RulesFile | A source file containing some Firebase security rules. The content includes raw source code including text formatting, indentation and comments. Use the SecurityRules.createRulesFileFromSource() method to create new instances of this type. |
Variables
| Variable | Description |
|---|---|
| SecurityRulesErrorCode | The constant mapping for valid Security Rules client error codes. |
Type Aliases
| Type Alias | Description |
|---|---|
| SecurityRulesErrorCode | The type definition for valid Security Rules client error codes. |
getSecurityRules(app)
Gets the SecurityRules service for the default app or a given app.
admin.securityRules() can be called with no arguments to access the default app's SecurityRules service, or as admin.securityRules(app) to access the SecurityRules service associated with a specific app.
Signature:
export declare function getSecurityRules(app?: App): SecurityRules;
Parameters
| Parameter | Type | Description |
|---|---|---|
| app | App | Optional app to return the SecurityRules service for. If not provided, the default SecurityRules service is returned. |
Returns:
The default SecurityRules service if no app is provided, or the SecurityRules service associated with the provided app.
Example 1
// Get the SecurityRules service for the default app
const defaultSecurityRules = getSecurityRules();
Example 2
// Get the SecurityRules service for a given app
const otherSecurityRules = getSecurityRules(otherApp);
SecurityRulesErrorCode
The constant mapping for valid Security Rules client error codes.
Signature:
SecurityRulesErrorCode: {
readonly ALREADY_EXISTS: "already-exists";
readonly AUTHENTICATION_ERROR: "authentication-error";
readonly INTERNAL_ERROR: "internal-error";
readonly INVALID_ARGUMENT: "invalid-argument";
readonly INVALID_SERVER_RESPONSE: "invalid-server-response";
readonly NOT_FOUND: "not-found";
readonly RESOURCE_EXHAUSTED: "resource-exhausted";
readonly SERVICE_UNAVAILABLE: "service-unavailable";
readonly UNKNOWN_ERROR: "unknown-error";
}
SecurityRulesErrorCode
The type definition for valid Security Rules client error codes.
Signature:
export type SecurityRulesErrorCode = typeof SecurityRulesErrorCode[keyof typeof SecurityRulesErrorCode];