Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace utils

Index

References

Namespaces

Variables

Functions

References

Renames and re-exports default

Variables

Callback: { middleware: (cb: (err: null | Error, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: undefined | Entity) => void) => (req: ExpressRequest, res: ServerResponse) => void; verifyCallback: (callbackBody: CallbackPayload, contentSignature: string) => Promise<boolean>; verifyMessage: (callbackBody: CallbackPayload, contentSignature: string, signingKey: string) => boolean }

Type declaration

  • middleware: (cb: (err: null | Error, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: undefined | Entity) => void) => (req: ExpressRequest, res: ServerResponse) => void
      • (cb: (err: null | Error, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: undefined | Entity) => void): (req: ExpressRequest, res: ServerResponse) => void
      • example

        Express style middleware

        app.post('/your/api', cw.utils.middleware((err, req, res, verified, payload) => {
        if (err) {
        //handle error
        res.status(500).end();
        } else if (!verified) {
        // send 403 on verification failure
        res.status(403).end();
        } else {
        res.status(200).end()
        }
        const {action, id} = req.query;
        // do something with the payload
        }));

        Parameters

        • cb: (err: null | Error, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: undefined | Entity) => void

          callback(err, req, res, verified, payload)

            • (err: null | Error, req: ExpressRequest, res: ServerResponse, verified: boolean, payload: undefined | Entity): void
            • Parameters

              Returns void

        Returns (req: ExpressRequest, res: ServerResponse) => void

  • verifyCallback: (callbackBody: CallbackPayload, contentSignature: string) => Promise<boolean>
      • (callbackBody: CallbackPayload, contentSignature: string): Promise<boolean>
      • Load signing key and verify the message

        Parameters

        • callbackBody: CallbackPayload
        • contentSignature: string

          base64 content signature req.headers[x-content-signature]

        Returns Promise<boolean>

        verifies callback signature

  • verifyMessage: (callbackBody: CallbackPayload, contentSignature: string, signingKey: string) => boolean
      • (callbackBody: CallbackPayload, contentSignature: string, signingKey: string): boolean
      • Validate a callback body against signed key

        Parameters

        Returns boolean

        boolean if verified

Functions

  • reportInterpolate(...args: { column_definitions?: {}[]; row_values?: {}[][] }[]): Record<string, unknown>[]
  • Transform a report column/value response object into an array

    Parameters

    • Rest ...args: { column_definitions?: {}[]; row_values?: {}[][] }[]

    Returns Record<string, unknown>[]

Generated using TypeDoc