
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@alessiofrittoli/crypto-algorithm
Advanced tools
Lightweight TypeScript library with Node.js Crypto Algortihm utilities
Run the following command to start using crypto-algorithm
in your projects:
npm i @alessiofrittoli/crypto-algorithm
or using pnpm
pnpm i @alessiofrittoli/crypto-algorithm
The Algorithm
class is designed to manage cryptographic algorithm schemas, including their mappings and retrievals based on various criteria.
The Algorithm
class provides utilities to manage and retrieve cryptographic algorithm specifications. The specifications include details like key type (kty
), cryptographic algorithm identifier (alg
), curve parameters, hash functions, and web crypto API names.
The algorithms supported by this class conform to COSE Algorithms and the Web Cryptography API.
KTY
A map of key type constants. The supported key types are:
Key | Value | Description |
---|---|---|
OKP | 1 | Octet Key Pair |
EC2 | 2 | Elliptic Curve (2) |
RSA | 3 | RSA |
Algorithm.MAP
A Map object that associates algorithm identifiers with their corresponding schemas. The schema includes:
kty
: Key type.alg
: Algorithm identifier.crv
: Curve identifier (for elliptic curves).name
: Name of the algorithm.hash
: Hash function used.crvSchemeName
: Curve scheme name.namedCurve
: Named curve for elliptic curve algorithms.webcryptoName
: Corresponding Web Crypto API algorithm name.jwkAlg
: JSON Web Key (JWK) algorithm name.Algorithm.by()
Retrieves an algorithm schema based on a partial schema or KeyAlgorithm
.
scheme
(Partial<Algo.Schema> | KeyAlgorithm)
: A partial schema or KeyAlgorithm object.(Algo.Schema | undefined)
: The matching algorithm schema, or undefined
if no match is found.alg
property, the method directly retrieves the schema from the Algorithm.MAP
.Algorithm.MAP
entries and performs a property-based match.Algorithm.byId()
Retrieves an algorithm schema by its identifier.
alg
(Algo.Id): The algorithm identifier.(Algo.Schema | undefined)
: The schema associated with the provided identifier, or undefined
if no match is found.Algorithm.by()
method with an object containing the alg
property.import { Algorithm } from '@alessiofrittoli/crypto-algorithm'
const schema = Algorithm.byId( -7 )
console.log( schema )
// Output: Schema details for ECDSA using SHA-256
import { Algorithm } from '@alessiofrittoli/crypto-algorithm'
import type { Algo } from '@alessiofrittoli/crypto-algorithm/types'
const partialScheme: Partial<Algo.Schema> = { name: 'RSA-PSS', hash: 'SHA-256' }
const schema = Algorithm.by( partialScheme )
console.log( schema )
// Output: Schema details for RSA-PSS with SHA-256
Algorithm.MAP
The Algorithm.MAP
includes schemas for:
ECDSA
(Elliptic Curve Digital Signature Algorithm)EdDSA
(Edwards-curve Digital Signature Algorithm)RSA-PSS
(RSA Probabilistic Signature Scheme)RSASSA-PKCS1-v1_5
(RSA Signature Scheme with Appendix)HMAC
(Hash-based Message Authentication Code)DSA
(Digital Signature Algorithm)Refer to the Algorithm.MAP implementation for specific algorithm configurations.
npm install
or using pnpm
pnpm i
Run the following command to test and build code for distribution.
pnpm build
warnings / errors check.
pnpm lint
Run all the defined test suites by running the following:
# Run tests and watch file changes.
pnpm test:watch
# Run tests in a CI environment.
pnpm test:ci
package.json
file scripts for more info.Run tests with coverage.
An HTTP server is then started to serve coverage files from ./coverage
folder.
⚠️ You may see a blank page the first time you run this command. Simply refresh the browser to see the updates.
test:coverage:serve
Contributions are truly welcome!
Please refer to the Contributing Doc for more information on how to start contributing to this project.
Help keep this project up to date with GitHub Sponsor.
If you believe you have found a security vulnerability, we encourage you to responsibly disclose this and NOT open a public issue. We will investigate all legitimate reports. Email security@alessiofrittoli.it
to disclose any security vulnerabilities.
|
|
FAQs
Lightweight TypeScript library with Node.js Crypto Algortihm utilities
The npm package @alessiofrittoli/crypto-algorithm receives a total of 15 weekly downloads. As such, @alessiofrittoli/crypto-algorithm popularity was classified as not popular.
We found that @alessiofrittoli/crypto-algorithm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.