import { Backend } from "../backend"; import { Resource as _Resource } from "../../resource"; import { Root, ReadItem, CreateItem, Params } from "../../action"; import { Filter } from "../../filter"; import { Schema } from "../../schema"; import * as query from "../../query"; import { Request } from "hapi"; /** * Security backend that performs authentication using a Prism Resource */ export declare class Resource implements Backend { readonly resource: _Resource; protected _options: Options; schema: Schema; constructor(resource: _Resource, options?: Partial); issue: (params: Params, request: Request) => Promise; issueQuery: (params: Params, request: Request) => Promise; validateQuery: (decoded: any, request: Request) => Promise; validate: (decoded: any, request: Request) => Promise; register: import("../../source").Source; filters: (Filter | Filter | Filter)[]; } /** * Configuration options for the `Resource` security backend */ export interface Options { /** * The resource property that contains a human-readable identity, such as a * username or email address * @default `"username"` */ identity: string; /** * The resource property that contains a secret string, ie password * @default `"password"` */ password: string; /** * Automatically replace the value of `password` within Documents that are generated by the bound Resource * @default `"**REDACTED**"` */ redact: string; /** * The comparison function that will be used to check `password` when a token * is issued, typically involving some kind of cryptographic hashing strategy. * * @param given The password that was specified when attempting to issue a * token * @param actual The actual value that the resource query returned * @return Promise that resolves to `true` if `given` matches `actual`, * otherwise resolves to `false` * @default A Promisified version of `bcrypt.compare` */ compare: (given: string, actual: string) => Promise; /** * The hashing function that will be used to automatically hash passwords when * creating or updating a document in the bound `Resource`. * * @param given The password to be hashed * @return Promise that resolves to the hashed value of `password` * @default A Promisified version of `bcrypt.hash` using 10 rounds. */ hash: (given: string) => Promise; /** * Additional `Condition` clauses to apply when performing queries during token * issuing and verification */ scope: query.Condition[]; }