Class BaseLoginAccountStorage<T>

A LoginStorage that wraps around another IndexedStorage to add specific account requirements.

  • New accounts will be removed after expiration time, in seconds, default is 1800, if no login method was added to them in that time.
  • Non-login types can not be created until the associated account has at least 1 login method.
  • Login types can not be deleted if they are the last login of the associated account.

All of this is tracked by adding a new field to the account object, that keeps track of how many login objects are associated with the account.

Type Parameters

Implements

Constructors

Properties

accountKeys: Dict<string>
loginTypes: string[]
storage: IndexedStorage<T>

Methods

  • Makes sure of the operation, adding or removing an object of the given type, is allowed, based on the current amount of login methods on the given account.

    Parameters

    • type: string
    • accountId: string
    • add: boolean

    Returns Promise<void>

  • Finds all objects matching a specific IndexedQuery.

    Type Parameters

    • TType extends string

    Parameters

    • type: TType

      The type of objects to find.

    • query: {
          [K in string | number | symbol]?: ValueType<T[TType][K]> | (T[TType][K] extends `id:${U}`
              ? {
                  [K in string | number | symbol]?: (ValueType<T[U][K]> | (T[U][K] extends `id:${infer U}` ? { [K in "id" | keyof T[U]]?: ValueType<T[U][K]> | (T[U][K] extends `id:${infer U}` ? { [K in "id" | keyof T[U]]?: ValueType<...> | ... 1 more ... | undefined; } : never) | undefined; } : never) | undefined)
              }
              : never)
      }

      The query to execute.

    Returns Promise<TypeObject<T[TType]>[]>

    A list of objects matching the query.

  • Similar to IndexedStorage.find, but only returns the identifiers of the found objects.

    Type Parameters

    • TType extends string

    Parameters

    • type: TType

      The type of objects to find.

    • query: {
          [K in string | number | symbol]?: ValueType<T[TType][K]> | (T[TType][K] extends `id:${U}`
              ? {
                  [K in string | number | symbol]?: (ValueType<T[U][K]> | (T[U][K] extends `id:${infer U}` ? { [K in "id" | keyof T[U]]?: ValueType<T[U][K]> | (T[U][K] extends `id:${infer U}` ? { [K in "id" | keyof T[U]]?: ValueType<...> | ... 1 more ... | undefined; } : never) | undefined; } : never) | undefined)
              }
              : never)
      }

      The query to execute.

    Returns Promise<string[]>

    A list of identifiers of the matching objects.