Security Rules for Cloud Firestore and Cloud Storage.

## Functions

| Function | Description |
|---|---|
| [getSecurityRules(app)](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules#getsecurityrules_8a40afc) | Gets the [SecurityRules](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.securityrules#securityrules_class) 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](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.firebasesecurityruleserror#firebasesecurityruleserror_class) | Firebase Security Rules error code structure. This extends `FirebaseError`. |
| [Ruleset](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.ruleset#ruleset_class) | A set of Firebase security rules. |
| [RulesetMetadataList](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.rulesetmetadatalist#rulesetmetadatalist_class) | A page of ruleset metadata. |
| [SecurityRules](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.securityrules#securityrules_class) | The Firebase `SecurityRules` service interface. |

## Interfaces

| Interface | Description |
|---|---|
| [RulesetMetadata](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.rulesetmetadata#rulesetmetadata_interface) | Required metadata associated with a ruleset. |
| [RulesFile](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.rulesfile#rulesfile_interface) | A source file containing some Firebase security rules. The content includes raw source code including text formatting, indentation and comments. Use the [SecurityRules.createRulesFileFromSource()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.securityrules#securityrulescreaterulesfilefromsource) method to create new instances of this type. |

## Variables

| Variable | Description |
|---|---|
| [SecurityRulesErrorCode](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules#securityruleserrorcode) | The constant mapping for valid Security Rules client error codes. |

## Type Aliases

| Type Alias | Description |
|---|---|
| [SecurityRulesErrorCode](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules#securityruleserrorcode) | The type definition for valid Security Rules client error codes. |

## getSecurityRules(app)

Gets the [SecurityRules](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.securityrules#securityrules_class) 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:**

[SecurityRules](https://firebase.google.com/docs/reference/admin/node/firebase-admin.security-rules.securityrules#securityrules_class)

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];