Options
All
  • Public
  • Public/Protected
  • All
Menu

HMAC signing utility. Methods are named after what it is to be signed, to allow for an easy to read code in the user application.

tutorial

https://wiki.foxycart.com/v/2.0/hmac_validation

example

const signer = new Signer(mySecret); // or const signer = new Signer(); signer.setSecret(mySecret); signer.signHtml('...'); // signs a URL signer.signFile("/var/www/html/src/.../index.html", "/var/www/html/target/.../index.html"); // signs an HTML file signer.signUrl("http://..."); // signs a URL

Hierarchy

  • Signer

Index

Constructors

  • new Signer(secret?: null | string): Signer
  • Creates an instance of this class.

    Parameters

    • secret: null | string = null

      OAuth2 client secret for your integration.

    Returns Signer

Properties

cartExcludePrefixes: string[] = ...
cartExcludes: string[] = ...

Methods

  • setSecret(secret: string): Signer
  • Sets the HMAC secret. It won't be possible to sign anything without this secret.

    Parameters

    • secret: string

      OAuth2 client secret for your integration.

    Returns Signer

    Signer to allow for convenient concatenation.

  • signFile(inputPath: string, outputPath: string, readFunc?: ((arg0: string) => Promise<JSDOM>), writeFunc?: ((path: string, content: string, callback: ((err: any) => void)) => void)): Promise<ParentNode>
  • Signs a file asynchronously.

    Parameters

    • inputPath: string

      Path of the file to sign.

    • outputPath: string

      Path of the file where the signed result will be stored.

    • readFunc: ((arg0: string) => Promise<JSDOM>) = JSDOM.fromFile

      a function that should read from file

        • (arg0: string): Promise<JSDOM>
        • Parameters

          • arg0: string

          Returns Promise<JSDOM>

    • writeFunc: ((path: string, content: string, callback: ((err: any) => void)) => void) = fs.writeFile

      a function that should write to to file

        • (path: string, content: string, callback: ((err: any) => void)): void
        • Parameters

          • path: string
          • content: string
          • callback: ((err: any) => void)
              • (err: any): void
              • Parameters

                • err: any

                Returns void

          Returns void

    Returns Promise<ParentNode>

    a ParentNode object of the signed HTML.

  • signHtml(htmlStr: string): string
  • Signs a whole HTML snippet.

    Parameters

    • htmlStr: string

      HTML snippet to sign.

    Returns string

    the HTML snippet signed.

  • signName(name: string, code: string, parentCode?: string, value?: string | number): string
  • Signs input name.

    Parameters

    • name: string

      Name of the input element.

    • code: string

      Product code.

    • parentCode: string = ''

      Parent product code.

    • Optional value: string | number

      Input value.

    Returns string

    the signed input name.

  • signUrl(urlStr: string): string
  • Signs a query string. All query fields withing the query string will be signed, provided it is a proper URL and there is a code field

    Parameters

    • urlStr: string

      Full URL including the query string that needs to be signed.

    Returns string

    the signed query string.

  • signValue(name: string, code: string, parentCode?: string, value?: string | number): string
  • Signs input value.

    Parameters

    • name: string

      Name of the input element.

    • code: string

      Product code.

    • parentCode: string = ''

      Parent product code.

    • Optional value: string | number

      Input value.

    Returns string

    the signed value.

Generated using TypeDoc