Options
All
  • Public
  • Public/Protected
  • All
Menu

@jahed/firebase-rules

Index

Type aliases

BooleanRule

BooleanRule: (val: RuleExpression<boolean, string>) => RuleExpression<boolean, string>

Type declaration

IndexField

IndexField: string

IndexRuleType

IndexRuleType: (...fields: IndexField[]) => RuleNodeFactory

Type declaration

NumberRule

NumberRule: (val: RuleExpression<number, string>) => RuleExpression<boolean, string>

Type declaration

PrimitiveOrExpression

PrimitiveOrExpression<T, R>: T | RuleExpression<T, R>

Type parameters

  • T = number | string | boolean

  • R = string | boolean

RuleAuth

RuleAuth: { provider: RuleString; token: RuleAuthToken; uid: RuleString }

Type declaration

RuleAuthToken

RuleAuthToken: { aud: RuleString; auth_time: RuleExpression<number, string>; email: RuleString; email_verified: RuleExpression<boolean, string>; exp: RuleExpression<number, string>; firebase: RuleAuthTokenFirebase; iat: RuleExpression<number, string>; iss: RuleString; name: RuleString; phone_number: RuleString; sub: RuleString }

Type declaration

RuleAuthTokenFirebase

RuleAuthTokenFirebase: { identities: { email: RuleString[]; facebook.com: RuleString[]; github.com: RuleString[]; google.com: RuleString[]; phone: RuleString[]; twitter.com: RuleString[] }; sign_in_provider: RuleString<RuleSignInProvider> }

Type declaration

RuleDataSnapshot

RuleDataSnapshot: { child: (...parts: PrimitiveOrExpression<string, string>[]) => RuleDataSnapshot; exists: () => RuleExpression<boolean, string>; hasChildren: (keys: string[]) => RuleExpression<boolean, string>; isBoolean: (rule?: BooleanRule) => RuleExpression<boolean, string>; isNumber: (rule?: NumberRule) => RuleExpression<boolean, string>; isString: (rule?: StringRule) => RuleExpression<boolean, string> }

Type declaration

RuleExpression

RuleExpression<_ReturnType, SerialisedType>: () => SerialisedType

Type parameters

  • _ReturnType = string | boolean | number

  • SerialisedType = string

Type declaration

    • (): SerialisedType
    • Returns SerialisedType

RuleNode

RuleNode: {}

Type declaration

  • [key: string]: RuleNode | string | boolean | string[]

RuleNodeFactory

RuleNodeFactory: (node?: RuleNode) => RuleNode

Type declaration

RuleSignInProvider

RuleSignInProvider: "custom" | "password" | "phone" | "anonymous" | "google.com" | "facebook.com" | "github.com" | "twitter.com"

RuleString

RuleString<T>: RuleExpression<T, string> & { contains: (substr: PrimitiveOrExpression<string>) => RuleExpression<boolean, string>; length: RuleExpression<number, string>; matches: (regexp: RegExp) => RuleExpression<boolean, string> }

Type parameters

  • T: string = string

RuleType

RuleType: (validator: RuleExpression<boolean, string | boolean>) => RuleNodeFactory

Type declaration

Rules

Rules: { rules: RuleNode }

Type declaration

StringRule

StringRule: (val: RuleString) => RuleExpression<boolean, string>

Type declaration

Variables

Const auth

auth: RuleAuth = createRuleAuth('auth')

Representation of auth for use in rule expressions.

https://firebase.google.com/docs/reference/security/database#auth

Const data

data: RuleDataSnapshot = createRuleDataSnapshot('data')

Representation of data for use in rule expressions.

https://firebase.google.com/docs/reference/security/database#data

Const newData

newData: RuleDataSnapshot = createRuleDataSnapshot('newData')

Representation of newData for use in rule expressions.

https://firebase.google.com/docs/reference/security/database#newdata

Const root

root: RuleDataSnapshot = createRuleDataSnapshot('root')

Representation of root for use in rule expressions.

https://firebase.google.com/docs/reference/security/database#root

Const value

value: IndexField = ".value"

Representation of ".value" to be used in indexOn rules.

Functions

Const add

Const allOf

Const allowAll

  • allowAll(): true
  • Returns a strictly true expression.

    read(allowAll) is the same as { ".read": false }

    Returns true

Const between

Const concat

Const createRuleAuth

  • createRuleAuth(name: string): RuleAuth

Const createRuleAuthToken

Const createRuleAuthTokenFirebase

Const createRuleDataSnapshot

Const createRulePrimitive

  • A representation of a Firebase Rule primitive such as a number or boolean.

    Type parameters

    • T

    Parameters

    • name: string

    Returns RuleExpression<T, string>

Const createRuleString

Const createRuleStringArray

  • createRuleStringArray(name: string): RuleString[]

Const denyAll

  • denyAll(): false
  • Returns a strictly false expression.

    read(denyAll) is the same as { ".read": false }

    Returns false

Const divide

Const equal

Const greaterThan

Const indexOn

  • indexOn(...fields: IndexField[]): (Anonymous function)

Const lessThan

Const modulus

Const multiply

Const negate

Const node

Const not

Const now

  • now(): string

Const oneOf

Const param

Const props

  • Defines multiple properties with their own rules.

    node(props({ one: node(), two: node() }))

    is the same as

    { "one": { }, "two": { } }

    Parameters

    Returns RuleNodeFactory

Const read

  • read(expression: RuleExpression<boolean, string | false | true>): (Anonymous function)

Const subtract

Const toJSONString

Const validate

  • validate(expression: RuleExpression<boolean, string | false | true>): (Anonymous function)

Const write

  • write(expression: RuleExpression<boolean, string | false | true>): (Anonymous function)

Generated using TypeDoc