npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pagopa/io-react-native-crypto

v1.0.1

Published

test

Downloads

2,627

Readme

@pagopa/io-react-native-crypto

Module to generate and sign with crypto keys backed on device security hardware on react-native platform.

Installation

yarn add @pagopa/io-react-native-crypto

Usage

Generate a key

import { generate } from '@pagopa/io-react-native-crypto';

// ...

try {
  const result = await generate('PERSONAL_KEYTAG');
} catch (e) {
  const {message, userInfo} = e as CryptoError;
}
// result is the JWK of the generated public key

Sign a message

import { sign } from '@pagopa/io-react-native-crypto';

// ...

try {
  const result = await sign('A valid message to sign', 'PERSONAL_KEYTAG');
} catch (e) {
  const {message, userInfo} = e as CryptoError;
}
// result is the Base64 string representation of the signature.

Retrieve the public key

import { getPublicKey } from '@pagopa/io-react-native-crypto';

// ...

try {
  const result = await getPublicKey('PERSONAL_KEYTAG');
} catch (e) {
  const {message, userInfo} = e as CryptoError;
}
// result is the JWK of the generated public key, error if no key has been yet generated

Checks whether a key is stored in StrongBox or not (Android only, raises a UNSUPPORTED_DEVICE error on iOS)

import { isKeyStrongboxBacked } from '@pagopa/io-react-native-crypto';

// ...

try {
  const isKeyStrongboxBacked = await isKeyStrongboxBacked('PERSONAL_KEYTAG');
  if(isKeyStrongboxBacked) {
    console.log('The key is stored in the StrongBox');
  } else {
    console.log('The key is stored in TEE');
  }
} catch (e) {
  const {message, userInfo} = e as CryptoError;
}
// result is the JWK of the generated public key, error if no key has been yet generated

Delete the key

import { deleteKey } from '@pagopa/io-react-native-crypto';

// ...

try {
  await deleteKey('PERSONAL_KEYTAG');
} catch (e) {
  const {message, userInfo} = e as CryptoError;
}
// no result is provided, error if no key has been found for the specified keytag

Types

| TypeName | Description | | :---------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ECKey | The JWK representation of an Elliptic Curve public key | | RSAKey | The JWK representation of an RSA public key | | PublicKey | Type of the returned public key, may be either a RSAKey or a ECKey | | CryptoError | This type defines the error returned by the generation of a key or signing a message it is composed by an error code and by an additional information object |

Error Codes

| TypeName | Platform | Description | | :-----------------------: | :---------: | ----------------------------------------------------------------------- | | KEY_ALREADY_EXISTS | iOS/Android | The key you're trying to generate already exists | | UNSUPPORTED_DEVICE | iOS/Android | Device doesn't support hardware backed keys or the requested method | | WRONG_KEY_CONFIGURATION | iOS/Android | The key configuration has not been correctly defined | | PUBLIC_KEY_NOT_FOUND | iOS/Android | The public key is missing for a specific keyTag | | PUBLIC_KEY_DELETION_ERROR | iOS/Android | An error occurred while deleting the public key | | API_LEVEL_NOT_SUPPORTED | Android | The current API Level doesn't support the hardware baked key generation | | KEYSTORE_LOAD_FAILED | Android | It was not possible to load or store data on the Keystore | | KEYCHAIN_LOAD_FAILED | iOS | It was not possible to load or store data on the Keychain | | UNABLE_TO_SIGN | iOS/Android | It was not possible to sign the given string | | INVALID_UTF8_ENCODING | iOS/Android | The encoded string doesn't respect the valid encoding format | | INVALID_SIGN_ALGORITHM | Android | The sign algorithm was not valid | | UNKNOWN_EXCEPTION | Android | Unexpected error | | THREADING_ERROR | iOS | Unexpected error |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library