@pnpm/crypto.integrity
Parse and validate integrity strings
Last updated 4 months ago by pnpmuser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @pnpm/crypto.integrity 
SYNC missed versions from official npm registry.

@pnpm/crypto.integrity

Parse and format integrity strings

Utilities for working with single-hash integrity strings in the format algorithm-base64hash (e.g., sha512-abc123...). This is the format used in pnpm lockfiles.

Installation

pnpm add @pnpm/crypto.integrity

Usage

import { parseIntegrity } from '@pnpm/crypto.integrity'

const { algorithm, hexDigest } = parseIntegrity('sha512-9/u6bgY2+JDlb7vzKD5STG+jIErimDgtYkdB0NxmODJuKCxBvl5CVNiCB3LFUYosWowMf37aGVlKfrU5RT4e1w==')

console.log(algorithm)  // 'sha512'
console.log(hexDigest)  // 'f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7'

API

parseIntegrity(integrity: string): ParsedIntegrity

Parses an integrity string and returns the algorithm and hex-encoded digest.

Throws PnpmError with code INVALID_INTEGRITY if:

  • The format is invalid (must be algorithm-base64hash)
  • The base64 hash decodes to an empty digest

formatIntegrity(algorithm: string, hexDigest: string): string

Formats a hex digest into an integrity string.

import { formatIntegrity } from '@pnpm/crypto.integrity'

const integrity = formatIntegrity('sha512', 'f7fbba6e...')
// 'sha512-9/u6bgY2+JDlb7vzKD5STG+...'

License

MIT

Current Tags

  • 1100.0.9                                ...           latest (2 months ago)

11 Versions

  • 1100.0.9                                ...           2 months ago
  • 1100.0.8                                ...           2 months ago
  • 1100.0.7                                ...           2 months ago
  • 1100.0.6                                ...           3 months ago
  • 1100.0.5                                ...           3 months ago
  • 1100.0.4                                ...           3 months ago
  • 1100.0.3                                ...           4 months ago
  • 1100.0.2                                ...           4 months ago
  • 1100.0.1                                ...           5 months ago
  • 1100.0.0                                ...           8 months ago
  • 1100.0.0-0                                ...           9 months ago
Maintainers (2)
Downloads
Total 58
Today 0
This Week 0
This Month 29
Last Day 0
Last Week 4
Last Month 29
Dependencies (1)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE