diff --git a/LICENSE b/LICENSE index a2bc77d..101d17f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2020 Vitalii Goma +Copyright (c) 2021 Artem Vasilev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7a6b7fe..011ac16 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,18 @@ # cryptoPro -Единое, асинхронное API для взаимодействия с КриптоПРО ЭЦП Browser Plug-In +Асинхронный JavaScript API для работы с КриптоПРО ЭЦП Browser Plug-In -> :warning: **Это форк проекта [vgoma/crypto-pro](https://github.com/vgoma/crypto-pro)** +> **Это форк проекта [vgoma/crypto-pro](https://github.com/vgoma/crypto-pro)** > -> :warning: **API форка отличается от оригинала**: внимательно читайте README +> **API форка отличается от оригинала**: внимательно читайте README | [![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/62.2.25/src/chrome/chrome_64x64.png)](https://www.chromium.org/getting-involved/download-chromium#TOC-Downloading-old-builds-of-Chrome-Chromium) | [![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/62.2.25/src/firefox/firefox_64x64.png)](https://ftp.mozilla.org/pub/firefox/releases/) | [![IE](https://raw.githubusercontent.com/alrra/browser-logos/62.2.25/src/archive/internet-explorer_9-11/internet-explorer_9-11_64x64.png)](https://www.microsoft.com/ru-ru/download/details.aspx?id=43374) | [![Opera](https://raw.githubusercontent.com/alrra/browser-logos/62.2.25/src/opera/opera_64x64.png)](http://get.opera.com/ftp/pub/opera/desktop/) | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | __v45+__ с расширением [CryptoPro Extension for CAdES Browser Plug-in](https://chrome.google.com/webstore/detail/cryptopro-extension-for-c/iifchhfnnmpdbibifmljnfjhpififfog?utm_source=chrome-app-launcher-info-dialog) | __v43+__. Начиная с версии 52, с [расширением](https://www.cryptopro.ru/sites/default/files/products/cades/extensions/cryptopro_extension_for_cades_browser_plug_in-1.1.1-an+fx-windows.xpi) | __v9+__ с установленным [КриптоПро ЭЦП Browser plug-in](https://www.cryptopro.ru/products/cades/plugin) | __v40+__ с расширением [CryptoPro Extension for CAdES Browser Plug-in](https://addons.opera.com/en/extensions/details/cryptopro-extension-for-cades-browser-plug-in/) | +## Ошибка `Параметр задан неверно. (0x80070057)` +Если при попытке подписать сообщение с использованием PKCS#7 подписи падает такая ошибка, то читайте [этот issue](https://github.com/webmasterskaya/crypto-pro-js/issues/20) - [cryptoPro](#cryptopro) - [Зачем мне этот пакет?](#why) @@ -25,12 +27,9 @@ - [Поддерживаемые СКЗИ](#supported-cist) - [Примеры](#examples) - [Тэг script (UMD)](#example-script-tag) - - [Angular (ES Modules + Typescript)](#example-angular) - - [React (ES Modules + JavaScript)](#example-react) - [Тем, кто хочет помочь](#developers) - [Запуск режима разработки](#dev-mode) - [Запуск тестов](#tests-execution) - - [Проверка работы примеров с React и Angular](#examples-testing) - [Проверка пакета перед публикацией в NPM](#final-check) - [Лицензия](#lisense) @@ -44,22 +43,22 @@ ## Установка Для NPM: ```bash -npm install crypto-pro +npm install crypto-pro-js ``` Для Yarn: ```bash -yarn add crypto-pro +yarn add crypto-pro-js ``` Для Bower: ```bash -bower install crypto-pro +bower install webmasterskaya/crypto-pro-js ``` Подключение пакета как UMD модуля через тэг script: ```html - + - - diff --git a/examples/react/public/logo192.png b/examples/react/public/logo192.png deleted file mode 100644 index fc44b0a..0000000 Binary files a/examples/react/public/logo192.png and /dev/null differ diff --git a/examples/react/public/logo512.png b/examples/react/public/logo512.png deleted file mode 100644 index a4e47a6..0000000 Binary files a/examples/react/public/logo512.png and /dev/null differ diff --git a/examples/react/public/manifest.json b/examples/react/public/manifest.json deleted file mode 100644 index 080d6c7..0000000 --- a/examples/react/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/react/public/robots.txt b/examples/react/public/robots.txt deleted file mode 100644 index e9e57dc..0000000 --- a/examples/react/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/examples/react/src/App.js b/examples/react/src/App.js deleted file mode 100644 index dc8e28e..0000000 --- a/examples/react/src/App.js +++ /dev/null @@ -1,119 +0,0 @@ -import React, { useState } from 'react'; -import { createAttachedSignature, createDetachedSignature, createHash } from 'crypto-pro'; -import Message from './components/Message'; -import Certificate from './components/Certificate'; -import SignatureType from './components/SignatureType'; -import Hash from './components/Hash'; -import Signature from './components/Signature'; -import SystemInfo from './components/SystemInfo'; - -function App() { - const [message, setMessage] = useState(''); - const [certificate, setCertificate] = useState(null); - const [detachedSignature, setSignatureType] = useState(null); - const [hash, setHash] = useState(''); - const [hashStatus, setHashStatus] = useState('Не вычислен'); - const [hashError, setHashError] = useState(null); - const [signature, setSignature] = useState(''); - const [signatureStatus, setSignatureStatus] = useState('Не создана'); - const [signatureError, setSignatureError] = useState(null); - - async function createSignature(event) { - let hash; - - event.preventDefault(); - - setSignature(''); - setSignatureError(null); - - setHash(''); - setHashError(null); - setHashStatus('Вычисляется...'); - - try { - hash = await createHash(message); - - setHash(hash); - } catch (error) { - setHashError(error.message); - - return; - } - - setHashStatus('Не вычислен'); - setSignatureStatus('Создается...'); - - if (detachedSignature) { - try { - setSignature(await createDetachedSignature(certificate.thumbprint, hash)); - } catch (error) { - setSignatureError(error.message); - } - - setSignatureStatus('Не создана'); - - return; - } - - try { - setSignature(await createAttachedSignature(certificate.thumbprint, message)); - } catch (error) { - setSignatureError(error.message); - } - - setSignatureStatus('Не создана'); - } - - return ( - <> -
-
- - -

- - - - - -

-
- - -
-
- -
- - - - -

- Для проверки нужно - создать файл со сгенерированной подписью в кодировке UTF-8 с расширением *.sgn -
- для отделенной подписи (или *.sig для совмещенной). -

-
- -
- -
- - ); -} - -export default App; diff --git a/examples/react/src/App.test.js b/examples/react/src/App.test.js deleted file mode 100644 index b70ea69..0000000 --- a/examples/react/src/App.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import App from './App'; - -xtest('renders learn react link', () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/examples/react/src/components/Certificate.js b/examples/react/src/components/Certificate.js deleted file mode 100644 index 327d1a4..0000000 --- a/examples/react/src/components/Certificate.js +++ /dev/null @@ -1,101 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { getCertificate, getUserCertificates } from 'crypto-pro'; - -function Certificate({onChange}) { - const [certificates, setCertificates] = useState([]); - const [certificatesError, setCertificatesError] = useState([]); - const [certificate, setCertificate] = useState(null); - const [certificateDetails, setCertificateDetails] = useState(null); - const [detailsError, setDetailsError] = useState(null); - - function selectCertificate(event) { - const certificate = certificates.find(({thumbprint}) => thumbprint === event.target.value); - - setCertificate(certificate); - onChange(certificate); - } - - async function loadCertificateDetails(thumbprint) { - try { - const certificate = await getCertificate(thumbprint); - - setCertificateDetails({ - name: certificate.name, - issuerName: certificate.issuerName, - subjectName: certificate.subjectName, - thumbprint: certificate.thumbprint, - validFrom: certificate.validFrom, - validTo: certificate.validTo, - isValid: await certificate.isValid(), - version: await certificate.getCadesProp('Version'), - base64: await certificate.exportBase64(), - algorithm: await certificate.getAlgorithm(), - extendedKeyUsage: await certificate.getExtendedKeyUsage(), - ownerInfo: await certificate.getOwnerInfo(), - issuerInfo: await certificate.getIssuerInfo(), - decodedExtendedKeyUsage: await certificate.getDecodedExtendedKeyUsage(), - '1.3.6.1.4.1.311.80.1': await certificate.hasExtendedKeyUsage('1.3.6.1.4.1.311.80.1'), - '[\'1.3.6.1.5.5.7.3.2\', \'1.3.6.1.4.1.311.10.3.12\']': await certificate.hasExtendedKeyUsage([ - '1.3.6.1.5.5.7.3.2', - '1.3.6.1.4.1.311.10.3.12' - ]), - '1.3.6.1.4.1.311.80.2': await certificate.hasExtendedKeyUsage('1.3.6.1.4.1.311.80.2'), - '\'1.3.6.1.5.5.7.3.3\', \'1.3.6.1.4.1.311.10.3.12\'': await certificate.hasExtendedKeyUsage([ - '1.3.6.1.5.5.7.3.3', - '1.3.6.1.4.1.311.10.3.12' - ]), - }); - } catch (error) { - setDetailsError(error); - } - } - - useEffect(() => { - (async () => { - try { - setCertificates(await getUserCertificates()); - } catch (error) { - setCertificatesError(error.message); - } - })(); - }); - - return ( - <> - - -
- - - -
{certificatesError || null}
- - {certificate ? ( - <> -
- Информация о сертификате - -
-              {certificateDetails ? (
-                JSON.stringify(certificateDetails, null, '  ')
-              ) : 'Запрашивается...'}
-            
-
- -
{detailsError || null}
- - ) : null} - - ); -} - -export default Certificate; diff --git a/examples/react/src/components/Hash.js b/examples/react/src/components/Hash.js deleted file mode 100644 index f4f3185..0000000 --- a/examples/react/src/components/Hash.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -function Hash({hash, hashStatus, hashError}) { - return ( - <> - Результат - - - -
- -