How to use the ow.number function in ow

To help you get started, we’ve selected a few ow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArkEcosystem / core / packages / core-config / lib / interface.js View on Github external
_validateConfig () {
    try {
      ow(this.network.pubKeyHash, ow.number)
      ow(this.network.nethash, ow.string.length(64))
      ow(this.network.wif, ow.number)
    } catch (error) {
      console.error('Invalid configuration. Shutting down...')
      throw Error(error.message)
      process.exit(1) // eslint-disable-line no-unreachable
    }
  }
}
github transitive-bullshit / captcha-solver / packages / captcha-solver-provider-anti-captcha / index.js View on Github external
body.task.type = 'NoCaptchaTask'
        break

      case 'nocaptcha-proxyless':
      case 'recaptcha-proxyless':
        ow(opts.websiteURL, ow.string.nonEmpty)
        ow(opts.websiteKey, ow.string.nonEmpty)
        body.task.type = 'NoCaptchaTaskProxyless'
        break

      case 'funcaptcha':
        ow(opts.websiteURL, ow.string.nonEmpty)
        ow(opts.websitePublicKey, ow.string.nonEmpty)
        ow(opts.proxyType, ow.string.nonEmpty)
        ow(opts.proxyAddress, ow.string.nonEmpty)
        ow(opts.proxyPort, ow.number.positive)
        ow(opts.userAgent, ow.string.nonEmpty)

        body.task.type = 'FunCaptchaTask'
        break

      case 'funcaptcha-proxyless':
        ow(opts.websiteURL, ow.string.nonEmpty)
        ow(opts.websitePublicKey, ow.string.nonEmpty)

        body.task.type = 'FunCaptchaTaskProxyless'
        break

      default:
        throw new Error(`unsupported task type "${opts.type}"`)
    }
github Julien-Broyard / JikanTS / src / search.ts View on Github external
filters?: Filters
) => {
  try {
    ow(page, ow.number.positive);
    ow(query, ow.string.minLength(3));

    const url = new URL(`/search/${type}?q=${query}&page=${page}`, baseUrl);

    if (filters) {
      if (filters.end_date) {
        filters.end_date = new Date(filters.end_date).toISOString();
      }

      if (filters.genre) {
        ow(filters.genre, ow.number.lessThanOrEqual(44));
        ow(filters.genre, ow.number.greaterThanOrEqual(1));
      }

      if (filters.limit) {
        ow(filters.limit, ow.number.positive);
      }

      if (filters.score) {
        ow(filters.score, ow.number.positive);
      }

      if (filters.start_date) {
        filters.start_date = new Date(filters.start_date).toISOString();
      }

      Object.entries(filters).forEach(([key, value]) => {
        url.searchParams.append(key, value);
github lukechilds / create-xpub / src / index.js View on Github external
const createXpub = ({networkVersion = XPUB, depth, childNumber, chainCode, publicKey}) => {
	ow(networkVersion, ow.number.label('networkVersion'));
	ow(depth, ow.number.label('depth'));
	ow(childNumber, ow.number.label('childNumber'));
	ow(chainCode, ow.string.label('chainCode'));
	ow(publicKey, ow.string.label('publicKey'));

	publicKey = compressPublicKey(publicKey);
	const fingerprint = getPublicKeyFingerprint(publicKey);

	const xpub = Buffer.from([
		networkVersion.toString(16).padStart(8, '0'),
		depth.toString(16).padStart(2, '0'),
		fingerprint.toString(16).padStart(8, '0'),
		childNumber.toString(16).padStart(8, '0'),
		chainCode,
		publicKey
	].join(''), 'hex');
github transitive-bullshit / primitive / lib / browser-context.js View on Github external
export const createImage = (width, height, fillColor = undefined) => {
  ow(width, ow.number.label('width').positive.integer)
  ow(height, ow.number.label('height').positive.integer)

  const canvas = document.createElement('canvas')
  canvas.width = width
  canvas.height = height
  const ctx = canvas.getContext('2d')
  if (fillColor) {
    ctx.fillStyle = cssrgba(fillColor)
    ctx.fillRect(0, 0, width, height)
  }
  return ctx.getImageData(0, 0, width, height)
}
github KishanBagaria / padding-oracle-attacker / src / response-analysis.ts View on Github external
async function analyseResponses({
  url, blockSize, logMode = 'full', concurrency = 128, isCacheEnabled = true, saveResponsesToTmpDir = true, ...args
}: ResponseAnalysisOptions) {
  ow(blockSize, ow.number)
  ow(concurrency, ow.number)

  const tmpDirPath = saveResponsesToTmpDir ? (await tmp.dir({ prefix: 'poattack_' })).path : ''
  if (['full', 'minimal'].includes(logMode)) await logStart({ url, blockSize, tmpDirPath })

  const { callOracle, networkStats } = OracleCaller({ url, isCacheEnabled, ...args })

  const statusCodeFreq: {[key: string]: number} = {}
  const bodyLengthFreq: {[key: string]: number} = {}
  const responses: {[key: number]: OracleResultWithPayload} = {}
  const fsPromises: Promise[] = []
  const rows: string[][] = []
  async function processByte(byte: number) {
    const twoBlocks = Buffer.alloc(blockSize * 2)
    twoBlocks[blockSize - 1] = byte
    const req = await callOracle(twoBlocks)
    const res = { ...req, payload: twoBlocks }
github atomiclabs / hyperdex / app / renderer / api.js View on Github external
constructor({endpoint, rpcPassword, concurrency = Infinity}) {
		ow(endpoint, 'endpoint', ow.string);
		ow(rpcPassword, 'rpcPassword', ow.string);
		ow(concurrency, 'concurrency', ow.number.positive.integerOrInfinite);

		this.endpoint = endpoint;
		this.rpcPassword = rpcPassword;
		this.queue = new PQueue({concurrency});
	}
github Julien-Broyard / JikanTS / src / search.ts View on Github external
const search = async (
  query: string,
  type: SearchTypes,
  page: number = 1,
  filters?: Filters
) => {
  try {
    ow(page, ow.number.positive);
    ow(query, ow.string.minLength(3));

    const url = new URL(`/search/${type}?q=${query}&page=${page}`, baseUrl);

    if (filters) {
      if (filters.end_date) {
        filters.end_date = new Date(filters.end_date).toISOString();
      }

      if (filters.genre) {
        ow(filters.genre, ow.number.lessThanOrEqual(44));
        ow(filters.genre, ow.number.greaterThanOrEqual(1));
      }

      if (filters.limit) {
        ow(filters.limit, ow.number.positive);
github lukechilds / create-xpub / src / index.js View on Github external
const createXpub = ({networkVersion = XPUB, depth, childNumber, chainCode, publicKey}) => {
	ow(networkVersion, ow.number.label('networkVersion'));
	ow(depth, ow.number.label('depth'));
	ow(childNumber, ow.number.label('childNumber'));
	ow(chainCode, ow.string.label('chainCode'));
	ow(publicKey, ow.string.label('publicKey'));

	publicKey = compressPublicKey(publicKey);
	const fingerprint = getPublicKeyFingerprint(publicKey);

	const xpub = Buffer.from([
		networkVersion.toString(16).padStart(8, '0'),
		depth.toString(16).padStart(2, '0'),
		fingerprint.toString(16).padStart(8, '0'),
		childNumber.toString(16).padStart(8, '0'),
		chainCode,
		publicKey
	].join(''), 'hex');