mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2025-04-21 13:03:07 +03:00
Compare commits
No commits in common. "master" and "2.3.0" have entirely different histories.
46
.github/workflows/test.yml
vendored
46
.github/workflows/test.yml
vendored
@ -1,46 +0,0 @@
|
|||||||
name: CryptoPRO tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
buildAndTest:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [ 16 ]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Clean install, build, test
|
|
||||||
run: |
|
|
||||||
npm ci
|
|
||||||
npm run build --if-present --openssl-legacy-provider
|
|
||||||
npm test
|
|
||||||
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Use Node.js 16
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 16
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Clean install, lint
|
|
||||||
run: |
|
|
||||||
npm ci
|
|
||||||
npm run lint
|
|
3
.travis.yml
Normal file
3
.travis.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- lts/*
|
1
LICENSE
1
LICENSE
@ -1,7 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 Vitalii Goma
|
Copyright (c) 2020 Vitalii Goma
|
||||||
Copyright (c) 2021 Artem Vasilev
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
106
README.md
106
README.md
@ -1,23 +1,20 @@
|
|||||||
[![License][license-image]][license-url]
|
|
||||||
[![NPM version][npm-version-image]][npm-url]
|
[![NPM version][npm-version-image]][npm-url]
|
||||||
[![NPM downloads][npm-downloads-image]][downloads-url]
|
[![NPM downloads][npm-downloads-image]][downloads-url]
|
||||||
[![Build Status][actions-image]][actions-url]
|
[![Build Status][travis-image]][travis-url]
|
||||||
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
<a name="cryptopro"></a>
|
<a name="cryptopro"></a>
|
||||||
# cryptoPro
|
# cryptoPro
|
||||||
Асинхронный JavaScript API для работы с КриптоПРО ЭЦП Browser Plug-In
|
Единое, асинхронное API для взаимодействия с КриптоПРО ЭЦП Browser Plug-In
|
||||||
|
|
||||||
> **Это форк проекта [vgoma/crypto-pro](https://github.com/vgoma/crypto-pro)**
|
> :warning: **Это форк проекта [vgoma/crypto-pro](https://github.com/vgoma/crypto-pro)**
|
||||||
>
|
>
|
||||||
> **API форка отличается от оригинала**: внимательно читайте README
|
> :warning: **API форка отличается от оригинала**: внимательно читайте README
|
||||||
|
|
||||||
| [](https://www.chromium.org/getting-involved/download-chromium#TOC-Downloading-old-builds-of-Chrome-Chromium) | [](https://ftp.mozilla.org/pub/firefox/releases/) | [](https://www.microsoft.com/ru-ru/download/details.aspx?id=43374) | [](http://get.opera.com/ftp/pub/opera/desktop/) |
|
| [](https://www.chromium.org/getting-involved/download-chromium#TOC-Downloading-old-builds-of-Chrome-Chromium) | [](https://ftp.mozilla.org/pub/firefox/releases/) | [](https://www.microsoft.com/ru-ru/download/details.aspx?id=43374) | [](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/) |
|
| __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)
|
- [cryptoPro](#cryptopro)
|
||||||
- [Зачем мне этот пакет?](#why)
|
- [Зачем мне этот пакет?](#why)
|
||||||
@ -28,9 +25,12 @@
|
|||||||
- [Поддерживаемые СКЗИ](#supported-cist)
|
- [Поддерживаемые СКЗИ](#supported-cist)
|
||||||
- [Примеры](#examples)
|
- [Примеры](#examples)
|
||||||
- [Тэг script (UMD)](#example-script-tag)
|
- [Тэг script (UMD)](#example-script-tag)
|
||||||
|
- [Angular (ES Modules + Typescript)](#example-angular)
|
||||||
|
- [React (ES Modules + JavaScript)](#example-react)
|
||||||
- [Тем, кто хочет помочь](#developers)
|
- [Тем, кто хочет помочь](#developers)
|
||||||
- [Запуск режима разработки](#dev-mode)
|
- [Запуск режима разработки](#dev-mode)
|
||||||
- [Запуск тестов](#tests-execution)
|
- [Запуск тестов](#tests-execution)
|
||||||
|
- [Проверка работы примеров с React и Angular](#examples-testing)
|
||||||
- [Проверка пакета перед публикацией в NPM](#final-check)
|
- [Проверка пакета перед публикацией в NPM](#final-check)
|
||||||
- [Лицензия](#lisense)
|
- [Лицензия](#lisense)
|
||||||
|
|
||||||
@ -44,22 +44,22 @@
|
|||||||
## Установка
|
## Установка
|
||||||
Для NPM:
|
Для NPM:
|
||||||
```bash
|
```bash
|
||||||
npm install crypto-pro-js
|
npm install crypto-pro
|
||||||
```
|
```
|
||||||
|
|
||||||
Для Yarn:
|
Для Yarn:
|
||||||
```bash
|
```bash
|
||||||
yarn add crypto-pro-js
|
yarn add crypto-pro
|
||||||
```
|
```
|
||||||
|
|
||||||
Для Bower:
|
Для Bower:
|
||||||
```bash
|
```bash
|
||||||
bower install webmasterskaya/crypto-pro-js
|
bower install crypto-pro
|
||||||
```
|
```
|
||||||
|
|
||||||
Подключение пакета как UMD модуля через тэг script:
|
Подключение пакета как UMD модуля через тэг script:
|
||||||
```html
|
```html
|
||||||
<script src="crypto-pro-js/dist/crypto-pro.min.js"></script>
|
<script src="crypto-pro/dist/crypto-pro.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
window.cryptoPro.getUserCertificates()
|
window.cryptoPro.getUserCertificates()
|
||||||
.then(function (certificates) {
|
.then(function (certificates) {
|
||||||
@ -73,7 +73,7 @@ window.cryptoPro.getUserCertificates()
|
|||||||
|
|
||||||
Подключение пакета как ES модуля с Typescript или JavaScript:
|
Подключение пакета как ES модуля с Typescript или JavaScript:
|
||||||
```typescript
|
```typescript
|
||||||
import { getUserCertificates, Certificate } from 'crypto-pro-js';
|
import { getUserCertificates, Certificate } from 'crypto-pro';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
let certificates: Certificate[];
|
let certificates: Certificate[];
|
||||||
@ -96,9 +96,6 @@ import { getUserCertificates, Certificate } from 'crypto-pro-js';
|
|||||||
<a name="api-cryptopro"></a>
|
<a name="api-cryptopro"></a>
|
||||||
### Методы объекта cryptoPro
|
### Методы объекта cryptoPro
|
||||||
- [getUserCertificates](src/api/getUserCertificates.ts) - возвращает список [сертификатов](#api-certificate), доступных пользователю в системе
|
- [getUserCertificates](src/api/getUserCertificates.ts) - возвращает список [сертификатов](#api-certificate), доступных пользователю в системе
|
||||||
- [getAllUserCertificates](src/api/getAllUserCertificates.ts) - возвращает список [сертификатов](#api-certificate), доступных пользователю в системе, в том числе просроченные и без закрытого ключа
|
|
||||||
- [getContainerCertificates](src/api/getContainerCertificates.ts) - возвращает список [сертификатов](#api-certificate), из закрытых ключей и/или сертификаты не установленные всистеме*
|
|
||||||
- [getAllContainerCertificates](src/api/getAllContainerCertificates.ts) - возвращает список [сертификатов](#api-certificate), из закрытых ключей и/или сертификаты не установленные всистеме*, в том числе просроченные и без закрытого ключа
|
|
||||||
- [getCertificate](src/api/getCertificate.ts) - возвращает [сертификат](#api-certificate) по отпечатку
|
- [getCertificate](src/api/getCertificate.ts) - возвращает [сертификат](#api-certificate) по отпечатку
|
||||||
- [createAttachedSignature](src/api/createAttachedSignature.ts) - создает совмещенную (присоединенную) подпись сообщения
|
- [createAttachedSignature](src/api/createAttachedSignature.ts) - создает совмещенную (присоединенную) подпись сообщения
|
||||||
- [createDetachedSignature](src/api/createDetachedSignature.ts) - создает отсоединенную (открепленную) подпись сообщения
|
- [createDetachedSignature](src/api/createDetachedSignature.ts) - создает отсоединенную (открепленную) подпись сообщения
|
||||||
@ -109,8 +106,6 @@ import { getUserCertificates, Certificate } from 'crypto-pro-js';
|
|||||||
- [getSystemInfo](src/api/getSystemInfo.ts) - возвращает информацию о CSP и плагине
|
- [getSystemInfo](src/api/getSystemInfo.ts) - возвращает информацию о CSP и плагине
|
||||||
- [isValidSystemSetup](src/api/isValidSystemSetup.ts) - возвращает флаг корректности настроек ЭП на машине
|
- [isValidSystemSetup](src/api/isValidSystemSetup.ts) - возвращает флаг корректности настроек ЭП на машине
|
||||||
|
|
||||||
> *Методы `getContainerCertificates` и `getAllContainerCertificates` позволяют получить сертификаты из закрытых ключей, записанных на обыкновенную флэшку
|
|
||||||
|
|
||||||
<a name="api-certificate"></a>
|
<a name="api-certificate"></a>
|
||||||
### Методы объекта сертификата
|
### Методы объекта сертификата
|
||||||
[Сертификат](src/api/certificate/certificate.ts) предоставляет следущее API:
|
[Сертификат](src/api/certificate/certificate.ts) предоставляет следущее API:
|
||||||
@ -140,6 +135,43 @@ npm i
|
|||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="example-angular"></a>
|
||||||
|
### Angular (ES Modules + Typescript)
|
||||||
|
```bash
|
||||||
|
cd examples/angular
|
||||||
|
npm i
|
||||||
|
```
|
||||||
|
|
||||||
|
Запуск в режиме разработки:
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Запуск в продакшн режиме:
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="example-react"></a>
|
||||||
|
### React (ES Modules + JavaScript)
|
||||||
|
```bash
|
||||||
|
cd examples/react
|
||||||
|
npm i
|
||||||
|
```
|
||||||
|
|
||||||
|
Запуск в режиме разработки:
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Запуск в продакшн режиме:
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<a name="developers"></a>
|
<a name="developers"></a>
|
||||||
# Тем, кто хочет помочь
|
# Тем, кто хочет помочь
|
||||||
Буду благодарен за расширение/улучшение/доработку API.
|
Буду благодарен за расширение/улучшение/доработку API.
|
||||||
@ -168,7 +200,7 @@ npm i
|
|||||||
npm link ../../
|
npm link ../../
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
> После выполнения `npm link ../../` в директории `examples/script-tag/node_modules` папка `crypto-pro-js` станет ярлыком,
|
> После выполнения `npm link ../../` в директории `examples/script-tag/node_modules` папка `crypto-pro` станет ярлыком,
|
||||||
> указывающим на папку содержащую локально собранный пакет.
|
> указывающим на папку содержащую локально собранный пакет.
|
||||||
|
|
||||||
<a name="tests-execution"></a>
|
<a name="tests-execution"></a>
|
||||||
@ -178,6 +210,32 @@ npm start
|
|||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="examples-testing"></a>
|
||||||
|
## Проверка работы примеров с React и Angular
|
||||||
|
React и Angular используют версию сборки пакета в формате ES модулей из директории `lib/`.
|
||||||
|
Для их запуска необходимо сначала собрать пакет выполнив:
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
После этого из папки `examples/angular` или `examples/react` залинковать пакет:
|
||||||
|
```bash
|
||||||
|
cd examples/angular
|
||||||
|
npm i
|
||||||
|
npm link ../../
|
||||||
|
```
|
||||||
|
|
||||||
|
И запустить пример в одном из двух режимов. В режиме разработки:
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
или в режиме продакшн:
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
|
||||||
<a name="final-check"></a>
|
<a name="final-check"></a>
|
||||||
## Проверка пакета перед публикацией в NPM
|
## Проверка пакета перед публикацией в NPM
|
||||||
Необходимо протестировать работу в заявленных браузерах, сделав это на локально запакованной версии пакета.
|
Необходимо протестировать работу в заявленных браузерах, сделав это на локально запакованной версии пакета.
|
||||||
@ -206,11 +264,11 @@ npm unlink
|
|||||||
# Лицензия
|
# Лицензия
|
||||||
[MIT](/LICENSE)
|
[MIT](/LICENSE)
|
||||||
|
|
||||||
[license-url]: /LICENSE
|
|
||||||
[license-image]: https://img.shields.io/github/license/webmasterskaya/crypto-pro-js
|
|
||||||
[npm-url]: https://npmjs.org/package/crypto-pro-js
|
[npm-url]: https://npmjs.org/package/crypto-pro-js
|
||||||
[npm-version-image]: https://img.shields.io/npm/v/crypto-pro-js.svg?style=flat
|
[npm-version-image]: https://img.shields.io/npm/v/crypto-pro-js.svg?style=flat
|
||||||
[npm-downloads-image]: https://img.shields.io/npm/dm/crypto-pro-js.svg?style=flat
|
[npm-downloads-image]: http://img.shields.io/npm/dm/crypto-pro-js.svg?style=flat
|
||||||
[downloads-url]: https://npmcharts.com/compare/crypto-pro-js?minimal=true
|
[downloads-url]: https://npmcharts.com/compare/crypto-pro-js?minimal=true
|
||||||
[actions-url]: https://github.com/webmasterskaya/crypto-pro-js/actions
|
[travis-url]: https://www.travis-ci.com/kernusr/crypto-pro-js
|
||||||
[actions-image]: https://img.shields.io/github/workflow/status/webmasterskaya/crypto-pro-js/test?event=push
|
[travis-image]: http://img.shields.io/travis/kernusr/crypto-pro-js/master.svg?style=flat
|
||||||
|
[coveralls-image]: https://coveralls.io/repos/github/kernusr/crypto-pro-js/badge.svg?branch=master
|
||||||
|
[coveralls-url]: https://coveralls.io/github/kernusr/crypto-pro-js?branch=master
|
||||||
|
10
bower.json
10
bower.json
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "crypto-pro-js",
|
"name": "crypto-pro",
|
||||||
"description": "Асинхронный JavaScript API для работы с КриптоПРО ЭЦП Browser Plug-In. Forked from https://github.com/vgoma/crypto-pro",
|
"description": "API для взаимодействия с КриптоПро",
|
||||||
"main": "./lib/crypto-pro-js.js",
|
"main": "./lib/crypto-pro.js",
|
||||||
"authors": [
|
"authors": [
|
||||||
"kern.usr <kern.usr@gmail.com>",
|
|
||||||
"vgoma <vgoma@yandex.ru>"
|
"vgoma <vgoma@yandex.ru>"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -11,12 +10,11 @@
|
|||||||
"crypto",
|
"crypto",
|
||||||
"cryptopro",
|
"cryptopro",
|
||||||
"crypto-pro",
|
"crypto-pro",
|
||||||
"crypto-pro-js",
|
|
||||||
"cades",
|
"cades",
|
||||||
"КриптоПро",
|
"КриптоПро",
|
||||||
"Крипто ПРО"
|
"Крипто ПРО"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/webmasterskaya/crypto-pro-js",
|
"homepage": "https://github.com/vgoma/crypto-pro",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"**/.*",
|
"**/.*",
|
||||||
"/*.js",
|
"/*.js",
|
||||||
|
8
dist/api/getAllCertificates.d.ts
vendored
8
dist/api/getAllCertificates.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Возвращает список сертификатов, доступных пользователю из пользовательского хранилища и закрытых ключей, не установленных в системе, без фильтрации по дате и наличию приватного ключа
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getAllCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
9
dist/api/getAllContainerCertificates.d.ts
vendored
9
dist/api/getAllContainerCertificates.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей
|
|
||||||
* Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getAllContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
3
dist/api/getCertificate.d.ts
vendored
3
dist/api/getCertificate.d.ts
vendored
@ -3,7 +3,6 @@ import { Certificate } from './certificate';
|
|||||||
* Возвращает сертификат по отпечатку
|
* Возвращает сертификат по отпечатку
|
||||||
*
|
*
|
||||||
* @param thumbprint - отпечаток сертификата
|
* @param thumbprint - отпечаток сертификата
|
||||||
* @param validOnly - проверять сертификаты по дате и наличию приватного ключа
|
|
||||||
* @returns сертификат
|
* @returns сертификат
|
||||||
*/
|
*/
|
||||||
export declare const getCertificate: (thumbprint: string, validOnly?: boolean) => Promise<Certificate>;
|
export declare const getCertificate: (thumbprint: string) => Promise<Certificate>;
|
||||||
|
8
dist/api/getCertificates.d.ts
vendored
8
dist/api/getCertificates.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Возвращает список сертификатов, доступных пользователю из пользовательского хранилища и закрытых ключей, не установленных в системе
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
9
dist/api/getContainerCertificates.d.ts
vendored
9
dist/api/getContainerCertificates.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей
|
|
||||||
* Возвращает список сертификатов, доступных пользователю в системе
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
4
dist/api/index.d.ts
vendored
4
dist/api/index.d.ts
vendored
@ -1,10 +1,6 @@
|
|||||||
export * from './getCertificate';
|
export * from './getCertificate';
|
||||||
export * from './getUserCertificates';
|
export * from './getUserCertificates';
|
||||||
export * from './getAllUserCertificates';
|
export * from './getAllUserCertificates';
|
||||||
export * from './getContainerCertificates';
|
|
||||||
export * from './getAllContainerCertificates';
|
|
||||||
export * from './getCertificates';
|
|
||||||
export * from './getAllCertificates';
|
|
||||||
export * from './getSystemInfo';
|
export * from './getSystemInfo';
|
||||||
export * from './isValidSystemSetup';
|
export * from './isValidSystemSetup';
|
||||||
export * from './createXMLSignature';
|
export * from './createXMLSignature';
|
||||||
|
4
dist/constants/oids-dictionary.d.ts
vendored
4
dist/constants/oids-dictionary.d.ts
vendored
@ -2,10 +2,6 @@ export declare const OIDS_DICTIONARY: {
|
|||||||
'1.2.643.2.2.34.6': string;
|
'1.2.643.2.2.34.6': string;
|
||||||
'1.2.643.2.39.1.1': string;
|
'1.2.643.2.39.1.1': string;
|
||||||
'1.2.643.3.131.1.1': string;
|
'1.2.643.3.131.1.1': string;
|
||||||
'1.2.643.100.4': string;
|
|
||||||
'1.2.643.100.1': string;
|
|
||||||
'1.2.643.100.5': string;
|
|
||||||
'1.2.643.100.3': string;
|
|
||||||
'1.2.643.3.141.1.1': string;
|
'1.2.643.3.141.1.1': string;
|
||||||
'1.2.643.3.141.1.2': string;
|
'1.2.643.3.141.1.2': string;
|
||||||
'1.2.643.3.2.100.65.13.11': string;
|
'1.2.643.3.2.100.65.13.11': string;
|
||||||
|
2
dist/crypto-pro-js.d.ts
vendored
2
dist/crypto-pro-js.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
// Type definitions for crypto-pro-js 2.3.3
|
// Type definitions for crypto-pro-js 2.3.0
|
||||||
// Project: crypto-pro-js
|
// Project: crypto-pro-js
|
||||||
// Definitions by: Artem Vasilev https://github.com/kernusr
|
// Definitions by: Artem Vasilev https://github.com/kernusr
|
||||||
|
|
||||||
|
973
dist/crypto-pro-js.js
vendored
973
dist/crypto-pro-js.js
vendored
File diff suppressed because one or more lines are too long
2
dist/crypto-pro-js.js.map
vendored
2
dist/crypto-pro-js.js.map
vendored
File diff suppressed because one or more lines are too long
6
dist/crypto-pro-js.min.js
vendored
6
dist/crypto-pro-js.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/crypto-pro-js.min.js.map
vendored
2
dist/crypto-pro-js.min.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/helpers/_extractCommonName.d.ts
vendored
2
dist/helpers/_extractCommonName.d.ts
vendored
@ -1 +1 @@
|
|||||||
export declare const _extractCommonName: (subjectName: string) => string | undefined;
|
export declare const _extractCommonName: (subjectName: string) => string;
|
||||||
|
@ -1 +1 @@
|
|||||||
export declare const _extractMeaningfulErrorMessage: (error: Error) => string | null;
|
export declare const _extractMeaningfulErrorMessage: (error: Error) => string;
|
||||||
|
7
dist/helpers/_getCadesContainerCert.d.ts
vendored
7
dist/helpers/_getCadesContainerCert.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Возвращает сертификат в формате Cades по отпечатку из хранилища закрытого ключа
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @returns сертификат в формате Cades
|
|
||||||
*/
|
|
||||||
export declare const _getCadesContainerCert: (thumbprint: string) => Promise<any>;
|
|
7
dist/helpers/_getCadesUserCert.d.ts
vendored
7
dist/helpers/_getCadesUserCert.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Возвращает сертификат в формате Cades по отпечатку из хранилища пользователя
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @returns сертификат в формате Cades
|
|
||||||
*/
|
|
||||||
export declare const _getCadesUserCert: (thumbprint: string) => Promise<any>;
|
|
13
examples/angular/.editorconfig
Normal file
13
examples/angular/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Editor configuration, see https://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
46
examples/angular/.gitignore
vendored
Normal file
46
examples/angular/.gitignore
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/tmp
|
||||||
|
/out-tsc
|
||||||
|
# Only exists if Bazel was run
|
||||||
|
/bazel-out
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# profiling files
|
||||||
|
chrome-profiler-events*.json
|
||||||
|
speed-measure-plugin*.json
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history/*
|
||||||
|
|
||||||
|
# misc
|
||||||
|
/.sass-cache
|
||||||
|
/connect.lock
|
||||||
|
/coverage
|
||||||
|
/libpeerconnection.log
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
testem.log
|
||||||
|
/typings
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
27
examples/angular/README.md
Normal file
27
examples/angular/README.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Angular
|
||||||
|
|
||||||
|
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.7.
|
||||||
|
|
||||||
|
## Development server
|
||||||
|
|
||||||
|
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||||
|
|
||||||
|
## Running end-to-end tests
|
||||||
|
|
||||||
|
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||||
|
|
||||||
|
## Further help
|
||||||
|
|
||||||
|
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
124
examples/angular/angular.json
Normal file
124
examples/angular/angular.json
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"angular": {
|
||||||
|
"projectType": "application",
|
||||||
|
"schematics": {},
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"prefix": "app",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist/angular",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"main": "src/main.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
"aot": true,
|
||||||
|
"assets": [
|
||||||
|
"src/favicon.ico",
|
||||||
|
"src/assets"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"extractCss": true,
|
||||||
|
"namedChunks": false,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb",
|
||||||
|
"maximumError": "10kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "angular:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "angular:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "angular:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "src/test.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"karmaConfig": "karma.conf.js",
|
||||||
|
"assets": [
|
||||||
|
"src/favicon.ico",
|
||||||
|
"src/assets"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"tsconfig.app.json",
|
||||||
|
"tsconfig.spec.json",
|
||||||
|
"e2e/tsconfig.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"e2e": {
|
||||||
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
|
"options": {
|
||||||
|
"protractorConfig": "e2e/protractor.conf.js",
|
||||||
|
"devServerTarget": "angular:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"devServerTarget": "angular:serve:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
"defaultProject": "angular"
|
||||||
|
}
|
15
examples/angular/browserslist
Normal file
15
examples/angular/browserslist
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
"$basedir/node" "$basedir/node_modules/browserslist/cli.js" "$@"
|
||||||
|
ret=$?
|
||||||
|
else
|
||||||
|
node "$basedir/node_modules/browserslist/cli.js" "$@"
|
||||||
|
ret=$?
|
||||||
|
fi
|
||||||
|
exit $ret
|
32
examples/angular/e2e/protractor.conf.js
Normal file
32
examples/angular/e2e/protractor.conf.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// @ts-check
|
||||||
|
// Protractor configuration file, see link for more information
|
||||||
|
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||||
|
|
||||||
|
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type { import("protractor").Config }
|
||||||
|
*/
|
||||||
|
exports.config = {
|
||||||
|
allScriptsTimeout: 11000,
|
||||||
|
specs: [
|
||||||
|
'./src/**/*.e2e-spec.ts'
|
||||||
|
],
|
||||||
|
capabilities: {
|
||||||
|
browserName: 'chrome'
|
||||||
|
},
|
||||||
|
directConnect: true,
|
||||||
|
baseUrl: 'http://localhost:4200/',
|
||||||
|
framework: 'jasmine',
|
||||||
|
jasmineNodeOpts: {
|
||||||
|
showColors: true,
|
||||||
|
defaultTimeoutInterval: 30000,
|
||||||
|
print: function() {}
|
||||||
|
},
|
||||||
|
onPrepare() {
|
||||||
|
require('ts-node').register({
|
||||||
|
project: require('path').join(__dirname, './tsconfig.json')
|
||||||
|
});
|
||||||
|
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||||
|
}
|
||||||
|
};
|
23
examples/angular/e2e/src/app.e2e-spec.ts
Normal file
23
examples/angular/e2e/src/app.e2e-spec.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { AppPage } from './app.po';
|
||||||
|
import { browser, logging } from 'protractor';
|
||||||
|
|
||||||
|
describe('workspace-project App', () => {
|
||||||
|
let page: AppPage;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
page = new AppPage();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display welcome message', () => {
|
||||||
|
page.navigateTo();
|
||||||
|
expect(page.getTitleText()).toEqual('angular app is running!');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
// Assert that there are no errors emitted from the browser
|
||||||
|
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||||
|
expect(logs).not.toContain(jasmine.objectContaining({
|
||||||
|
level: logging.Level.SEVERE,
|
||||||
|
} as logging.Entry));
|
||||||
|
});
|
||||||
|
});
|
11
examples/angular/e2e/src/app.po.ts
Normal file
11
examples/angular/e2e/src/app.po.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { browser, by, element } from 'protractor';
|
||||||
|
|
||||||
|
export class AppPage {
|
||||||
|
navigateTo(): Promise<unknown> {
|
||||||
|
return browser.get(browser.baseUrl) as Promise<unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitleText(): Promise<string> {
|
||||||
|
return element(by.css('app-root .content span')).getText() as Promise<string>;
|
||||||
|
}
|
||||||
|
}
|
13
examples/angular/e2e/tsconfig.json
Normal file
13
examples/angular/e2e/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../out-tsc/e2e",
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"jasminewd2",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
32
examples/angular/karma.conf.js
Normal file
32
examples/angular/karma.conf.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Karma configuration file, see link for more information
|
||||||
|
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
basePath: '',
|
||||||
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
|
plugins: [
|
||||||
|
require('karma-jasmine'),
|
||||||
|
require('karma-chrome-launcher'),
|
||||||
|
require('karma-jasmine-html-reporter'),
|
||||||
|
require('karma-coverage-istanbul-reporter'),
|
||||||
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
|
],
|
||||||
|
client: {
|
||||||
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
|
},
|
||||||
|
coverageIstanbulReporter: {
|
||||||
|
dir: require('path').join(__dirname, './coverage/angular'),
|
||||||
|
reports: ['html', 'lcovonly', 'text-summary'],
|
||||||
|
fixWebpackSourcePaths: true
|
||||||
|
},
|
||||||
|
reporters: ['progress', 'kjhtml'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
singleRun: false,
|
||||||
|
restartOnFileChange: true
|
||||||
|
});
|
||||||
|
};
|
51
examples/angular/package.json
Normal file
51
examples/angular/package.json
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"name": "crypto-pro-example-angular",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "Пример использования пакета crypto-pro в typescript проекте с angular",
|
||||||
|
"scripts": {
|
||||||
|
"serve": "static --host-address localhost --port 8082 dist/angular",
|
||||||
|
"ng": "ng",
|
||||||
|
"start": "ng serve",
|
||||||
|
"build": "ng build",
|
||||||
|
"test": "ng test",
|
||||||
|
"lint": "ng lint",
|
||||||
|
"e2e": "ng e2e"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/animations": "~9.0.7",
|
||||||
|
"@angular/common": "~9.0.7",
|
||||||
|
"@angular/compiler": "~9.0.7",
|
||||||
|
"@angular/core": "~9.0.7",
|
||||||
|
"@angular/forms": "~9.0.7",
|
||||||
|
"@angular/platform-browser": "~9.0.7",
|
||||||
|
"@angular/platform-browser-dynamic": "~9.0.7",
|
||||||
|
"@angular/router": "~9.0.7",
|
||||||
|
"crypto-pro-js": "^2.3.0",
|
||||||
|
"rxjs": "~6.5.4",
|
||||||
|
"tslib": "^1.10.0",
|
||||||
|
"zone.js": "~0.10.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/build-angular": "~0.900.7",
|
||||||
|
"@angular/cli": "~9.0.7",
|
||||||
|
"@angular/compiler-cli": "~9.0.7",
|
||||||
|
"@angular/language-service": "~9.0.7",
|
||||||
|
"@types/jasmine": "~3.5.0",
|
||||||
|
"@types/jasminewd2": "~2.0.3",
|
||||||
|
"@types/node": "^12.11.1",
|
||||||
|
"codelyzer": "^5.1.2",
|
||||||
|
"jasmine-core": "~3.5.0",
|
||||||
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
|
"karma": "~4.3.0",
|
||||||
|
"karma-chrome-launcher": "~3.1.0",
|
||||||
|
"karma-coverage-istanbul-reporter": "~2.1.0",
|
||||||
|
"karma-jasmine": "~2.0.1",
|
||||||
|
"karma-jasmine-html-reporter": "^1.4.2",
|
||||||
|
"node-static": "0.7.11",
|
||||||
|
"protractor": "~5.4.3",
|
||||||
|
"ts-node": "~8.3.0",
|
||||||
|
"tslint": "~5.18.0",
|
||||||
|
"typescript": "~3.7.5"
|
||||||
|
}
|
||||||
|
}
|
0
examples/angular/src/app/app.component.css
Normal file
0
examples/angular/src/app/app.component.css
Normal file
1
examples/angular/src/app/app.component.html
Normal file
1
examples/angular/src/app/app.component.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<app-crypto-pro></app-crypto-pro>
|
24
examples/angular/src/app/app.component.spec.ts
Normal file
24
examples/angular/src/app/app.component.spec.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
|
describe('AppComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the app', () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
const app = fixture.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should have as title 'angular'`, () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
const app = fixture.componentInstance;
|
||||||
|
expect(app.title).toEqual('angular');
|
||||||
|
});
|
||||||
|
});
|
10
examples/angular/src/app/app.component.ts
Normal file
10
examples/angular/src/app/app.component.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-root',
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
styleUrls: ['./app.component.css']
|
||||||
|
})
|
||||||
|
export class AppComponent {
|
||||||
|
title = 'angular';
|
||||||
|
}
|
20
examples/angular/src/app/app.module.ts
Normal file
20
examples/angular/src/app/app.module.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
import { CryptoProComponent } from './crypto-pro/crypto-pro.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent,
|
||||||
|
CryptoProComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
FormsModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
bootstrap: [AppComponent]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
106
examples/angular/src/app/crypto-pro/crypto-pro.component.html
Normal file
106
examples/angular/src/app/crypto-pro/crypto-pro.component.html
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<form
|
||||||
|
#signatureForm="ngForm"
|
||||||
|
novalidate
|
||||||
|
(ngSubmit)="createSignature(thumbprint)">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Создание подписи</legend>
|
||||||
|
<label for="message">Подписываемое сообщение: *</label>
|
||||||
|
<br>
|
||||||
|
<textarea
|
||||||
|
id="message"
|
||||||
|
name="message"
|
||||||
|
cols="80"
|
||||||
|
rows="5"
|
||||||
|
placeholder="Введите сообщение"
|
||||||
|
autofocus
|
||||||
|
required
|
||||||
|
[(ngModel)]="message">Привет мир!</textarea>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<label for="certificate">Сертификат: *</label>
|
||||||
|
<br>
|
||||||
|
<select
|
||||||
|
id="certificate"
|
||||||
|
name="certificate"
|
||||||
|
required
|
||||||
|
[(ngModel)]="thumbprint">
|
||||||
|
<option value="null" disabled>Не выбран</option>
|
||||||
|
<option *ngFor="let cert of certificateList" [value]="cert.thumbprint">
|
||||||
|
{{cert.name + ' (действителен до: ' + cert.validTo + ')'}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<pre>{{certificateListError}}</pre>
|
||||||
|
|
||||||
|
<details
|
||||||
|
*ngIf="thumbprint"
|
||||||
|
(click)="showCertInfo(thumbprint)">
|
||||||
|
<summary>Информация о сертификате</summary>
|
||||||
|
<pre *ngIf="certInfo">{{certInfo | json}}</pre>
|
||||||
|
<pre *ngIf="!certInfo">Запрашивается...</pre>
|
||||||
|
</details>
|
||||||
|
<pre>{{certificateInfoError}}</pre>
|
||||||
|
|
||||||
|
<label>Тип подписи: *</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="detachedSignature"
|
||||||
|
[value]="false"
|
||||||
|
[(ngModel)]="detachedSignature">Совмещенная</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="detachedSignature"
|
||||||
|
[value]="true"
|
||||||
|
[(ngModel)]="detachedSignature">Отделенная</label>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
[disabled]="!signatureForm.valid">Создать подпись</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Результат</legend>
|
||||||
|
<label for="hash">Хеш (ГОСТ Р 34.11-2012 256 бит):</label><br>
|
||||||
|
<textarea
|
||||||
|
id="hash"
|
||||||
|
cols="80"
|
||||||
|
rows="5"
|
||||||
|
[(ngModel)]="hash"
|
||||||
|
[placeholder]="hashStatus"
|
||||||
|
></textarea>
|
||||||
|
<pre>{{hashError}}</pre>
|
||||||
|
|
||||||
|
<label for="signature">Подпись (PKCS7):</label><br>
|
||||||
|
<textarea
|
||||||
|
id="signature"
|
||||||
|
name="signature"
|
||||||
|
cols="80"
|
||||||
|
rows="30"
|
||||||
|
[placeholder]="signatureStatus"
|
||||||
|
[(ngModel)]="signature"
|
||||||
|
></textarea>
|
||||||
|
<pre>{{signatureError}}</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Для
|
||||||
|
<a href="https://www.gosuslugi.ru/pgu/eds/"
|
||||||
|
target="_blank"
|
||||||
|
rel="nofollow noopener noreferrer"
|
||||||
|
title="Перейти к проверке подписи">проверки</a>
|
||||||
|
нужно создать файл со сгенерированной подписью в кодировке UTF-8 с расширением *.sgn
|
||||||
|
<br>
|
||||||
|
для отделенной подписи (или *.sig для совмещенной).
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Информация о системе</legend>
|
||||||
|
<pre *ngIf="systemInfo">{{systemInfo | json}}</pre>
|
||||||
|
<pre>{{systemInfoError}}</pre>
|
||||||
|
</fieldset>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CryptoProComponent } from './crypto-pro.component';
|
||||||
|
|
||||||
|
describe('CryptoProComponent', () => {
|
||||||
|
let component: CryptoProComponent;
|
||||||
|
let fixture: ComponentFixture<CryptoProComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ CryptoProComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(CryptoProComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
144
examples/angular/src/app/crypto-pro/crypto-pro.component.ts
Normal file
144
examples/angular/src/app/crypto-pro/crypto-pro.component.ts
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import {
|
||||||
|
getCertificate,
|
||||||
|
getUserCertificates,
|
||||||
|
getSystemInfo,
|
||||||
|
isValidSystemSetup,
|
||||||
|
createHash,
|
||||||
|
createDetachedSignature,
|
||||||
|
createAttachedSignature,
|
||||||
|
SystemInfo,
|
||||||
|
Certificate
|
||||||
|
} from 'crypto-pro';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-crypto-pro',
|
||||||
|
templateUrl: './crypto-pro.component.html',
|
||||||
|
styleUrls: ['./crypto-pro.component.css']
|
||||||
|
})
|
||||||
|
export class CryptoProComponent implements OnInit {
|
||||||
|
public message = 'Привет мир!';
|
||||||
|
public certificateList: Certificate[] = [];
|
||||||
|
public hash: string = null;
|
||||||
|
public hashStatus = 'Не вычислен';
|
||||||
|
public detachedSignature = true;
|
||||||
|
public thumbprint: string = null;
|
||||||
|
public signature: string = null;
|
||||||
|
public signatureStatus = 'Не создана';
|
||||||
|
public systemInfo: SystemInfo & {
|
||||||
|
isValidSystemSetup: boolean;
|
||||||
|
};
|
||||||
|
public certificateListError: string = null;
|
||||||
|
public certificateInfoError: string = null;
|
||||||
|
public hashError: string = null;
|
||||||
|
public signatureError: string = null;
|
||||||
|
public systemInfoError: string = null;
|
||||||
|
public certInfo = null;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
public ngOnInit(): void {
|
||||||
|
this.displayCertificates();
|
||||||
|
this.displaySystemInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async createSignature(thumbprint) {
|
||||||
|
this.hash = null;
|
||||||
|
this.hashError = null;
|
||||||
|
this.signature = null;
|
||||||
|
this.signatureError = null;
|
||||||
|
this.hashStatus = 'Вычисляется...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.hash = await createHash(this.message);
|
||||||
|
} catch (error) {
|
||||||
|
this.hashError = error.message;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.hashStatus = 'Не вычислен';
|
||||||
|
this.signatureStatus = 'Создается...';
|
||||||
|
|
||||||
|
if (this.detachedSignature) {
|
||||||
|
try {
|
||||||
|
this.signature = await createDetachedSignature(thumbprint, this.hash);
|
||||||
|
} catch (error) {
|
||||||
|
this.signatureError = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.signatureStatus = 'Не создана';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.signature = await createAttachedSignature(thumbprint, this.message);
|
||||||
|
} catch (error) {
|
||||||
|
this.signatureError = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.signatureStatus = 'Не создана';
|
||||||
|
}
|
||||||
|
|
||||||
|
public async showCertInfo(thumbprint) {
|
||||||
|
this.certInfo = null;
|
||||||
|
this.certificateInfoError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const certificate = await getCertificate(thumbprint);
|
||||||
|
|
||||||
|
this.certInfo = {
|
||||||
|
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) {
|
||||||
|
this.certificateInfoError = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async displayCertificates() {
|
||||||
|
this.certificateListError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.certificateList = await getUserCertificates();
|
||||||
|
} catch (error) {
|
||||||
|
this.certificateListError = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async displaySystemInfo() {
|
||||||
|
this.systemInfoError = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.systemInfo = {
|
||||||
|
...await getSystemInfo(),
|
||||||
|
isValidSystemSetup: await isValidSystemSetup()
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
this.systemInfoError = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
0
examples/angular/src/assets/.gitkeep
Normal file
0
examples/angular/src/assets/.gitkeep
Normal file
3
examples/angular/src/environments/environment.prod.ts
Normal file
3
examples/angular/src/environments/environment.prod.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true
|
||||||
|
};
|
16
examples/angular/src/environments/environment.ts
Normal file
16
examples/angular/src/environments/environment.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// This file can be replaced during build by using the `fileReplacements` array.
|
||||||
|
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||||
|
// The list of file replacements can be found in `angular.json`.
|
||||||
|
|
||||||
|
export const environment = {
|
||||||
|
production: false
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For easier debugging in development mode, you can import the following file
|
||||||
|
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||||
|
*
|
||||||
|
* This import should be commented out in production mode because it will have a negative impact
|
||||||
|
* on performance if an error is thrown.
|
||||||
|
*/
|
||||||
|
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
BIN
examples/angular/src/favicon.ico
Normal file
BIN
examples/angular/src/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 948 B |
13
examples/angular/src/index.html
Normal file
13
examples/angular/src/index.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Angular</title>
|
||||||
|
<base href="/">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<app-root></app-root>
|
||||||
|
</body>
|
||||||
|
</html>
|
12
examples/angular/src/main.ts
Normal file
12
examples/angular/src/main.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { enableProdMode } from '@angular/core';
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
|
import { AppModule } from './app/app.module';
|
||||||
|
import { environment } from './environments/environment';
|
||||||
|
|
||||||
|
if (environment.production) {
|
||||||
|
enableProdMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
|
.catch(err => console.error(err));
|
63
examples/angular/src/polyfills.ts
Normal file
63
examples/angular/src/polyfills.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||||
|
* You can add your own extra polyfills to this file.
|
||||||
|
*
|
||||||
|
* This file is divided into 2 sections:
|
||||||
|
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
||||||
|
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
||||||
|
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||||
|
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||||
|
*
|
||||||
|
* Learn more in https://angular.io/guide/browser-support
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* BROWSER POLYFILLS
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
||||||
|
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web Animations `@angular/platform-browser/animations`
|
||||||
|
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||||
|
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||||
|
*/
|
||||||
|
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||||
|
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||||
|
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||||
|
* will put import in the top of bundle, so user need to create a separate file
|
||||||
|
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||||
|
* into that file, and then add the following code before importing zone.js.
|
||||||
|
* import './zone-flags';
|
||||||
|
*
|
||||||
|
* The flags allowed in zone-flags.ts are listed here.
|
||||||
|
*
|
||||||
|
* The following flags will work for all browsers.
|
||||||
|
*
|
||||||
|
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||||
|
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||||
|
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||||
|
*
|
||||||
|
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||||
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
*
|
||||||
|
* (window as any).__Zone_enable_cross_context_check = true;
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Zone JS is required by default for Angular itself.
|
||||||
|
*/
|
||||||
|
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* APPLICATION IMPORTS
|
||||||
|
*/
|
1
examples/angular/src/styles.css
Normal file
1
examples/angular/src/styles.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* You can add global styles to this file, and also import other style files */
|
25
examples/angular/src/test.ts
Normal file
25
examples/angular/src/test.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||||
|
|
||||||
|
import 'zone.js/dist/zone-testing';
|
||||||
|
import { getTestBed } from '@angular/core/testing';
|
||||||
|
import {
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting
|
||||||
|
} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
|
||||||
|
declare const require: {
|
||||||
|
context(path: string, deep?: boolean, filter?: RegExp): {
|
||||||
|
keys(): string[];
|
||||||
|
<T>(id: string): T;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// First, initialize the Angular testing environment.
|
||||||
|
getTestBed().initTestEnvironment(
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting()
|
||||||
|
);
|
||||||
|
// Then we find all the tests.
|
||||||
|
const context = require.context('./', true, /\.spec\.ts$/);
|
||||||
|
// And load the modules.
|
||||||
|
context.keys().map(context);
|
14
examples/angular/tsconfig.app.json
Normal file
14
examples/angular/tsconfig.app.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./out-tsc/app",
|
||||||
|
"types": []
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/main.ts",
|
||||||
|
"src/polyfills.ts"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"src/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
23
examples/angular/tsconfig.json
Normal file
23
examples/angular/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compileOnSave": false,
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": "./",
|
||||||
|
"outDir": "./dist/out-tsc",
|
||||||
|
"sourceMap": true,
|
||||||
|
"declaration": false,
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"importHelpers": true,
|
||||||
|
"target": "es2015",
|
||||||
|
"lib": [
|
||||||
|
"es2018",
|
||||||
|
"dom"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"fullTemplateTypeCheck": true,
|
||||||
|
"strictInjectionParameters": true
|
||||||
|
}
|
||||||
|
}
|
18
examples/angular/tsconfig.spec.json
Normal file
18
examples/angular/tsconfig.spec.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./out-tsc/spec",
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/test.ts",
|
||||||
|
"src/polyfills.ts"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"src/**/*.spec.ts",
|
||||||
|
"src/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
91
examples/angular/tslint.json
Normal file
91
examples/angular/tslint.json
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
"array-type": false,
|
||||||
|
"arrow-parens": false,
|
||||||
|
"deprecation": {
|
||||||
|
"severity": "warning"
|
||||||
|
},
|
||||||
|
"component-class-suffix": true,
|
||||||
|
"contextual-lifecycle": true,
|
||||||
|
"directive-class-suffix": true,
|
||||||
|
"directive-selector": [
|
||||||
|
true,
|
||||||
|
"attribute",
|
||||||
|
"app",
|
||||||
|
"camelCase"
|
||||||
|
],
|
||||||
|
"component-selector": [
|
||||||
|
true,
|
||||||
|
"element",
|
||||||
|
"app",
|
||||||
|
"kebab-case"
|
||||||
|
],
|
||||||
|
"import-blacklist": [
|
||||||
|
true,
|
||||||
|
"rxjs/Rx"
|
||||||
|
],
|
||||||
|
"interface-name": false,
|
||||||
|
"max-classes-per-file": false,
|
||||||
|
"max-line-length": [
|
||||||
|
true,
|
||||||
|
140
|
||||||
|
],
|
||||||
|
"member-access": false,
|
||||||
|
"member-ordering": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"order": [
|
||||||
|
"static-field",
|
||||||
|
"instance-field",
|
||||||
|
"static-method",
|
||||||
|
"instance-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-consecutive-blank-lines": false,
|
||||||
|
"no-console": [
|
||||||
|
true,
|
||||||
|
"debug",
|
||||||
|
"info",
|
||||||
|
"time",
|
||||||
|
"timeEnd",
|
||||||
|
"trace"
|
||||||
|
],
|
||||||
|
"no-empty": false,
|
||||||
|
"no-inferrable-types": [
|
||||||
|
true,
|
||||||
|
"ignore-params"
|
||||||
|
],
|
||||||
|
"no-non-null-assertion": true,
|
||||||
|
"no-redundant-jsdoc": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-var-requires": false,
|
||||||
|
"object-literal-key-quotes": [
|
||||||
|
true,
|
||||||
|
"as-needed"
|
||||||
|
],
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"trailing-comma": false,
|
||||||
|
"no-conflicting-lifecycle": true,
|
||||||
|
"no-host-metadata-property": true,
|
||||||
|
"no-input-rename": true,
|
||||||
|
"no-inputs-metadata-property": true,
|
||||||
|
"no-output-native": true,
|
||||||
|
"no-output-on-prefix": true,
|
||||||
|
"no-output-rename": true,
|
||||||
|
"no-outputs-metadata-property": true,
|
||||||
|
"template-banana-in-box": true,
|
||||||
|
"template-no-negated-async": true,
|
||||||
|
"use-lifecycle-interface": true,
|
||||||
|
"use-pipe-transform-interface": true
|
||||||
|
},
|
||||||
|
"rulesDirectory": [
|
||||||
|
"codelyzer"
|
||||||
|
]
|
||||||
|
}
|
1
examples/react/.env
Normal file
1
examples/react/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
SKIP_PREFLIGHT_CHECK=true
|
23
examples/react/.gitignore
vendored
Normal file
23
examples/react/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
68
examples/react/README.md
Normal file
68
examples/react/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
In the project directory, you can run:
|
||||||
|
|
||||||
|
### `npm start`
|
||||||
|
|
||||||
|
Runs the app in the development mode.<br />
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||||
|
|
||||||
|
The page will reload if you make edits.<br />
|
||||||
|
You will also see any lint errors in the console.
|
||||||
|
|
||||||
|
### `npm test`
|
||||||
|
|
||||||
|
Launches the test runner in the interactive watch mode.<br />
|
||||||
|
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||||
|
|
||||||
|
### `npm run build`
|
||||||
|
|
||||||
|
Builds the app for production to the `build` folder.<br />
|
||||||
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||||
|
|
||||||
|
The build is minified and the filenames include the hashes.<br />
|
||||||
|
Your app is ready to be deployed!
|
||||||
|
|
||||||
|
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||||
|
|
||||||
|
### `npm run eject`
|
||||||
|
|
||||||
|
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||||
|
|
||||||
|
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||||
|
|
||||||
|
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||||
|
|
||||||
|
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||||
|
|
||||||
|
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||||
|
|
||||||
|
### Code Splitting
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
|
||||||
|
|
||||||
|
### Analyzing the Bundle Size
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
|
||||||
|
|
||||||
|
### Making a Progressive Web App
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
|
||||||
|
|
||||||
|
### Advanced Configuration
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
|
||||||
|
|
||||||
|
### `npm run build` fails to minify
|
||||||
|
|
||||||
|
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
32998
examples/react/package-lock.json
generated
Normal file
32998
examples/react/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
examples/react/package.json
Normal file
41
examples/react/package.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "crypto-pro-example-react",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Пример использования пакета crypto-pro в javascript проекте с react",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@testing-library/jest-dom": "4.2.4",
|
||||||
|
"@testing-library/react": "9.5.0",
|
||||||
|
"@testing-library/user-event": "7.2.1",
|
||||||
|
"crypto-pro-js": "^2.3.0",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"react-app-polyfill": "1.0.6",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-scripts": "3.4.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"node-static": "0.7.11"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"serve": "static --host-address localhost --port 8081 build",
|
||||||
|
"start": "react-scripts start",
|
||||||
|
"build": "react-scripts build",
|
||||||
|
"test": "react-scripts test",
|
||||||
|
"eject": "react-scripts eject"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "react-app"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
76
examples/react/public/atob-btoa.js
Normal file
76
examples/react/public/atob-btoa.js
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define([], function () {
|
||||||
|
factory(root);
|
||||||
|
});
|
||||||
|
} else factory(root);
|
||||||
|
// node.js has always supported base64 conversions, while browsers that support
|
||||||
|
// web workers support base64 too, but you may never know.
|
||||||
|
})(typeof exports !== "undefined" ? exports : this, function (root) {
|
||||||
|
if (root.atob) {
|
||||||
|
// Some browsers' implementation of atob doesn't support whitespaces
|
||||||
|
// in the encoded string (notably, IE). This wraps the native atob
|
||||||
|
// in a function that strips the whitespaces.
|
||||||
|
// The original function can be retrieved in atob.original
|
||||||
|
try {
|
||||||
|
root.atob(" ");
|
||||||
|
} catch (e) {
|
||||||
|
root.atob = (function (atob) {
|
||||||
|
var func = function (string) {
|
||||||
|
return atob(String(string).replace(/[\t\n\f\r ]+/g, ""));
|
||||||
|
};
|
||||||
|
func.original = atob;
|
||||||
|
return func;
|
||||||
|
})(root.atob);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// base64 character set, plus padding character (=)
|
||||||
|
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
||||||
|
// Regular expression to check formal correctness of base64 encoded strings
|
||||||
|
b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
||||||
|
|
||||||
|
root.btoa = function (string) {
|
||||||
|
string = String(string);
|
||||||
|
var bitmap, a, b, c,
|
||||||
|
result = "", i = 0,
|
||||||
|
rest = string.length % 3; // To determine the final padding
|
||||||
|
|
||||||
|
for (; i < string.length;) {
|
||||||
|
if ((a = string.charCodeAt(i++)) > 255
|
||||||
|
|| (b = string.charCodeAt(i++)) > 255
|
||||||
|
|| (c = string.charCodeAt(i++)) > 255)
|
||||||
|
throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
|
||||||
|
|
||||||
|
bitmap = (a << 16) | (b << 8) | c;
|
||||||
|
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63)
|
||||||
|
+ b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's need of padding, replace the last 'A's with equal signs
|
||||||
|
return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result;
|
||||||
|
};
|
||||||
|
|
||||||
|
root.atob = function (string) {
|
||||||
|
// atob can work with strings with whitespaces, even inside the encoded part,
|
||||||
|
// but only \t, \n, \f, \r and ' ', which can be stripped.
|
||||||
|
string = String(string).replace(/[\t\n\f\r ]+/g, "");
|
||||||
|
if (!b64re.test(string))
|
||||||
|
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
||||||
|
|
||||||
|
// Adding the padding if missing, for semplicity
|
||||||
|
string += "==".slice(2 - (string.length & 3));
|
||||||
|
var bitmap, result = "", r1, r2, i = 0;
|
||||||
|
for (; i < string.length;) {
|
||||||
|
bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12
|
||||||
|
| (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
|
||||||
|
|
||||||
|
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
|
||||||
|
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
|
||||||
|
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
});
|
BIN
examples/react/public/favicon.ico
Normal file
BIN
examples/react/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
45
examples/react/public/index.html
Normal file
45
examples/react/public/index.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Web site created using create-react-app"
|
||||||
|
/>
|
||||||
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is installed on a
|
||||||
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
<!--
|
||||||
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>React App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
|
-->
|
||||||
|
<!-- Полифилл для работы демо в IE9 -->
|
||||||
|
<script src="atob-btoa.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
examples/react/public/logo192.png
Normal file
BIN
examples/react/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
examples/react/public/logo512.png
Normal file
BIN
examples/react/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
examples/react/public/manifest.json
Normal file
25
examples/react/public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
3
examples/react/public/robots.txt
Normal file
3
examples/react/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# https://www.robotstxt.org/robotstxt.html
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
119
examples/react/src/App.js
Normal file
119
examples/react/src/App.js
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
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 (
|
||||||
|
<>
|
||||||
|
<form onSubmit={createSignature} noValidate>
|
||||||
|
<fieldset>
|
||||||
|
<Message onChange={setMessage}/>
|
||||||
|
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
<Certificate onChange={setCertificate}/>
|
||||||
|
|
||||||
|
<SignatureType onChange={setSignatureType}/>
|
||||||
|
|
||||||
|
<br/><br/>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={!certificate || !message}>
|
||||||
|
Создать подпись
|
||||||
|
</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<Hash
|
||||||
|
hash={hash}
|
||||||
|
hashStatus={hashStatus}
|
||||||
|
hashError={hashError}/>
|
||||||
|
|
||||||
|
<Signature
|
||||||
|
signature={signature}
|
||||||
|
signatureStatus={signatureStatus}
|
||||||
|
signatureError={signatureError}/>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Для <a href="https://www.gosuslugi.ru/pgu/eds/"
|
||||||
|
target="_blank"
|
||||||
|
rel="nofollow noopener noreferrer"
|
||||||
|
title="Перейти к проверке подписи">проверки</a> нужно
|
||||||
|
создать файл со сгенерированной подписью в кодировке UTF-8 с расширением *.sgn
|
||||||
|
<br/>
|
||||||
|
для отделенной подписи (или *.sig для совмещенной).
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<SystemInfo/>
|
||||||
|
</fieldset>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
9
examples/react/src/App.test.js
Normal file
9
examples/react/src/App.test.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { render } from '@testing-library/react';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
xtest('renders learn react link', () => {
|
||||||
|
const { getByText } = render(<App />);
|
||||||
|
const linkElement = getByText(/learn react/i);
|
||||||
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
});
|
101
examples/react/src/components/Certificate.js
Normal file
101
examples/react/src/components/Certificate.js
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
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 (
|
||||||
|
<>
|
||||||
|
<label htmlFor="certificate">Сертификат: *</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<select id="certificate" onChange={selectCertificate}>
|
||||||
|
<option defaultValue={null}>Не выбран</option>
|
||||||
|
|
||||||
|
{certificates.map(({name, thumbprint, validTo}) =>
|
||||||
|
<option key={thumbprint} value={thumbprint}>
|
||||||
|
{name + ' (действителен до: ' + validTo + ')'}
|
||||||
|
</option>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<pre>{certificatesError || null}</pre>
|
||||||
|
|
||||||
|
{certificate ? (
|
||||||
|
<>
|
||||||
|
<details
|
||||||
|
onClick={loadCertificateDetails.bind(this, certificate.thumbprint)}>
|
||||||
|
<summary>Информация о сертификате</summary>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{certificateDetails ? (
|
||||||
|
JSON.stringify(certificateDetails, null, ' ')
|
||||||
|
) : 'Запрашивается...'}
|
||||||
|
</pre>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<pre>{detailsError || null}</pre>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Certificate;
|
25
examples/react/src/components/Hash.js
Normal file
25
examples/react/src/components/Hash.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
function Hash({hash, hashStatus, hashError}) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<legend>Результат</legend>
|
||||||
|
|
||||||
|
<label htmlFor="hash">Хеш (ГОСТ Р 34.11-2012 256 бит):</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
id="hash"
|
||||||
|
cols="80"
|
||||||
|
rows="5"
|
||||||
|
value={hash}
|
||||||
|
placeholder={hashStatus}
|
||||||
|
readOnly/>
|
||||||
|
|
||||||
|
<pre>{hashError || null}</pre>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Hash;
|
35
examples/react/src/components/Message.js
Normal file
35
examples/react/src/components/Message.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
function Message({onChange}) {
|
||||||
|
const [message, setMessage] = useState('Привет мир!');
|
||||||
|
|
||||||
|
function onMessageChange(event) {
|
||||||
|
setMessage(event.target.value);
|
||||||
|
onChange(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => onChange(message));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<legend>Создание подписи</legend>
|
||||||
|
|
||||||
|
<label htmlFor="message">Подписываемое сообщение: *</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
id="message"
|
||||||
|
name="message"
|
||||||
|
cols="80"
|
||||||
|
rows="5"
|
||||||
|
placeholder="Введите сообщение"
|
||||||
|
value={message}
|
||||||
|
onChange={onMessageChange}
|
||||||
|
autoFocus
|
||||||
|
required/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Message;
|
23
examples/react/src/components/Signature.js
Normal file
23
examples/react/src/components/Signature.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
function Signature({signature, signatureStatus, signatureError}) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<label htmlFor="signature">Подпись (PKCS7):</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
id="signature"
|
||||||
|
cols="80"
|
||||||
|
rows="30"
|
||||||
|
value={signature}
|
||||||
|
placeholder={signatureStatus}
|
||||||
|
readOnly/>
|
||||||
|
|
||||||
|
<pre>{signatureError || null}</pre>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Signature;
|
36
examples/react/src/components/SignatureType.js
Normal file
36
examples/react/src/components/SignatureType.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
function SignatureType({onChange}) {
|
||||||
|
const [type, setType] = useState(true);
|
||||||
|
|
||||||
|
function onTypeToggle() {
|
||||||
|
setType(!type);
|
||||||
|
onChange(!type);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => onChange(type));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<label>Тип подписи: *</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
checked={!type}
|
||||||
|
onChange={onTypeToggle}/>Совмещенная</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
checked={type}
|
||||||
|
onChange={onTypeToggle}/>Отделенная</label>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SignatureType;
|
36
examples/react/src/components/SystemInfo.js
Normal file
36
examples/react/src/components/SystemInfo.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { getSystemInfo, isValidSystemSetup } from 'crypto-pro';
|
||||||
|
|
||||||
|
function SystemInfo() {
|
||||||
|
const [systemInfo, setSystemInfo] = useState(null);
|
||||||
|
const [systemInfoError, setSystemInfoError] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
setSystemInfo({
|
||||||
|
...await getSystemInfo(),
|
||||||
|
isValidSystemSetup: await isValidSystemSetup()
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
setSystemInfoError(error.message);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<legend>Информация о системе</legend>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{systemInfo ? (
|
||||||
|
JSON.stringify(systemInfo, null, ' ')
|
||||||
|
) : (
|
||||||
|
systemInfoError || null
|
||||||
|
)}
|
||||||
|
</pre>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SystemInfo;
|
19
examples/react/src/index.js
Normal file
19
examples/react/src/index.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'react-app-polyfill/ie9';
|
||||||
|
import 'react-app-polyfill/stable';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import App from './App';
|
||||||
|
import * as serviceWorker from './serviceWorker';
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>,
|
||||||
|
document.getElementById('root')
|
||||||
|
);
|
||||||
|
|
||||||
|
// If you want your app to work offline and load faster, you can change
|
||||||
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
|
// Learn more about service workers: https://bit.ly/CRA-PWA
|
||||||
|
serviceWorker.unregister();
|
7
examples/react/src/logo.svg
Normal file
7
examples/react/src/logo.svg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||||
|
<g fill="#61DAFB">
|
||||||
|
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||||
|
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||||
|
<path d="M520.5 78.1z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
141
examples/react/src/serviceWorker.js
Normal file
141
examples/react/src/serviceWorker.js
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// This optional code is used to register a service worker.
|
||||||
|
// register() is not called by default.
|
||||||
|
|
||||||
|
// This lets the app load faster on subsequent visits in production, and gives
|
||||||
|
// it offline capabilities. However, it also means that developers (and users)
|
||||||
|
// will only see deployed updates on subsequent visits to a page, after all the
|
||||||
|
// existing tabs open on the page have been closed, since previously cached
|
||||||
|
// resources are updated in the background.
|
||||||
|
|
||||||
|
// To learn more about the benefits of this model and instructions on how to
|
||||||
|
// opt-in, read https://bit.ly/CRA-PWA
|
||||||
|
|
||||||
|
const isLocalhost = Boolean(
|
||||||
|
window.location.hostname === 'localhost' ||
|
||||||
|
// [::1] is the IPv6 localhost address.
|
||||||
|
window.location.hostname === '[::1]' ||
|
||||||
|
// 127.0.0.0/8 are considered localhost for IPv4.
|
||||||
|
window.location.hostname.match(
|
||||||
|
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
export function register(config) {
|
||||||
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
|
// The URL constructor is available in all browsers that support SW.
|
||||||
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||||
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
|
// from what our page is served on. This might happen if a CDN is used to
|
||||||
|
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
|
if (isLocalhost) {
|
||||||
|
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||||
|
checkValidServiceWorker(swUrl, config);
|
||||||
|
|
||||||
|
// Add some additional logging to localhost, pointing developers to the
|
||||||
|
// service worker/PWA documentation.
|
||||||
|
navigator.serviceWorker.ready.then(() => {
|
||||||
|
console.log(
|
||||||
|
'This web app is being served cache-first by a service ' +
|
||||||
|
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Is not localhost. Just register service worker
|
||||||
|
registerValidSW(swUrl, config);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerValidSW(swUrl, config) {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.register(swUrl)
|
||||||
|
.then(registration => {
|
||||||
|
registration.onupdatefound = () => {
|
||||||
|
const installingWorker = registration.installing;
|
||||||
|
if (installingWorker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
installingWorker.onstatechange = () => {
|
||||||
|
if (installingWorker.state === 'installed') {
|
||||||
|
if (navigator.serviceWorker.controller) {
|
||||||
|
// At this point, the updated precached content has been fetched,
|
||||||
|
// but the previous service worker will still serve the older
|
||||||
|
// content until all client tabs are closed.
|
||||||
|
console.log(
|
||||||
|
'New content is available and will be used when all ' +
|
||||||
|
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Execute callback
|
||||||
|
if (config && config.onUpdate) {
|
||||||
|
config.onUpdate(registration);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// At this point, everything has been precached.
|
||||||
|
// It's the perfect time to display a
|
||||||
|
// "Content is cached for offline use." message.
|
||||||
|
console.log('Content is cached for offline use.');
|
||||||
|
|
||||||
|
// Execute callback
|
||||||
|
if (config && config.onSuccess) {
|
||||||
|
config.onSuccess(registration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error during service worker registration:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValidServiceWorker(swUrl, config) {
|
||||||
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
|
fetch(swUrl, {
|
||||||
|
headers: { 'Service-Worker': 'script' },
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
|
const contentType = response.headers.get('content-type');
|
||||||
|
if (
|
||||||
|
response.status === 404 ||
|
||||||
|
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||||
|
) {
|
||||||
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
|
registration.unregister().then(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Service worker found. Proceed as normal.
|
||||||
|
registerValidSW(swUrl, config);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log(
|
||||||
|
'No internet connection found. App is running in offline mode.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unregister() {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.ready
|
||||||
|
.then(registration => {
|
||||||
|
registration.unregister();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
5
examples/react/src/setupTests.js
Normal file
5
examples/react/src/setupTests.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||||
|
// allows you to do things like:
|
||||||
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
|
import '@testing-library/jest-dom/extend-expect';
|
33
examples/script-tag/package-lock.json
generated
33
examples/script-tag/package-lock.json
generated
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "crypto-pro-example-es5-script-tag",
|
"name": "crypto-pro-example-es5-script-tag",
|
||||||
"version": "2.3.3",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "crypto-pro-example-es5-script-tag",
|
"name": "crypto-pro-example-es5-script-tag",
|
||||||
"version": "2.3.3",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"crypto-pro-js": "^2.3.3"
|
"crypto-pro-js": "^2.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-static": "0.7.11",
|
"node-static": "0.7.11",
|
||||||
@ -59,12 +59,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/crypto-pro-js": {
|
"node_modules/crypto-pro-js": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/crypto-pro-js/-/crypto-pro-js-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/crypto-pro-js/-/crypto-pro-js-2.3.0.tgz",
|
||||||
"integrity": "sha512-ge6PXRw6pu2kXeaqwEpHvmQEuSRQWJcVfQfPfF5gGONIi+jUHFsvkeS5ojFcKKBDqFHnYUQXFZ1aMKDGdoVRqg==",
|
"integrity": "sha512-pJ9vaQDdInhz2NhIE9NRj3mH6W7PsY+UQCwz7ZHrjgpVlTNWrg2Rk/ooorNfVuQUjOk3tbLYaLnMqkPkRgbmlA=="
|
||||||
"engines": {
|
|
||||||
"node": "~16"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/fs.realpath": {
|
"node_modules/fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -145,9 +142,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.2",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
@ -314,9 +311,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"crypto-pro-js": {
|
"crypto-pro-js": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/crypto-pro-js/-/crypto-pro-js-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/crypto-pro-js/-/crypto-pro-js-2.3.0.tgz",
|
||||||
"integrity": "sha512-ge6PXRw6pu2kXeaqwEpHvmQEuSRQWJcVfQfPfF5gGONIi+jUHFsvkeS5ojFcKKBDqFHnYUQXFZ1aMKDGdoVRqg=="
|
"integrity": "sha512-pJ9vaQDdInhz2NhIE9NRj3mH6W7PsY+UQCwz7ZHrjgpVlTNWrg2Rk/ooorNfVuQUjOk3tbLYaLnMqkPkRgbmlA=="
|
||||||
},
|
},
|
||||||
"fs.realpath": {
|
"fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -382,9 +379,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.1.2",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "crypto-pro-example-es5-script-tag",
|
"name": "crypto-pro-example-es5-script-tag",
|
||||||
"version": "2.3.3",
|
"version": "0.0.0",
|
||||||
"description": "Пример использования пакета crypto-pro через тэг script",
|
"description": "Пример использования пакета crypto-pro через тэг script",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"link-library": "symlink-dir ./node_modules/crypto-pro-js/dist ./public/dist",
|
"link-library": "symlink-dir ./node_modules/crypto-pro/dist ./public/dist",
|
||||||
"serve": "static --host-address localhost --port 8080 public",
|
"serve": "static --host-address localhost --port 8080 public",
|
||||||
"start": "npm run link-library && npm run serve"
|
"start": "npm run link-library && npm run serve"
|
||||||
},
|
},
|
||||||
@ -13,6 +13,6 @@
|
|||||||
"symlink-dir": "3.1.2"
|
"symlink-dir": "3.1.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"crypto-pro-js": "^2.3.3"
|
"crypto-pro-js": "^2.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
$certificateDetails.style.display = thumbprint ? 'block' : 'none';
|
$certificateDetails.style.display = thumbprint ? 'block' : 'none';
|
||||||
});
|
});
|
||||||
|
|
||||||
window.cryptoPro.getCertificates().then(function (certificateList) {
|
window.cryptoPro.getUserCertificates().then(function (certificateList) {
|
||||||
certificateList.forEach(function (certificate) {
|
certificateList.forEach(function (certificate) {
|
||||||
var $certOption = document.createElement('option');
|
var $certOption = document.createElement('option');
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
<script src="polyfills/find.js"></script>
|
<script src="polyfills/find.js"></script>
|
||||||
|
|
||||||
<!-- Библиотека -->
|
<!-- Библиотека -->
|
||||||
<script src="dist/crypto-pro-js.js"></script>
|
<script src="dist/crypto-pro.js"></script>
|
||||||
|
|
||||||
<!-- Полифиллы для работы демо скриптов -->
|
<!-- Полифиллы для работы демо скриптов -->
|
||||||
<script src="polyfills/atob-btoa.js"></script>
|
<script src="polyfills/atob-btoa.js"></script>
|
||||||
|
8
lib/api/addAttachedSignature.d.ts
vendored
8
lib/api/addAttachedSignature.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Добавляет присоединенную подпись к подписанному сообщению по отпечатку сертификата
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @param signedMessage - подписанное сообщение
|
|
||||||
* @returns подпись в формате PKCS#7
|
|
||||||
*/
|
|
||||||
export declare const addAttachedSignature: (thumbprint: string, signedMessage: string | ArrayBuffer) => Promise<string>;
|
|
9
lib/api/addDetachedSignature.d.ts
vendored
9
lib/api/addDetachedSignature.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* Добавляет отсоединенную подпись хеша к подписанному сообщению по отпечатку сертификата
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @param signedMessage - подписанное сообщение
|
|
||||||
* @param messageHash - хеш подписываемого сообщения, сгенерированный по ГОСТ Р 34.11-2012 256 бит
|
|
||||||
* @returns подпись в формате PKCS#7
|
|
||||||
*/
|
|
||||||
export declare const addDetachedSignature: (thumbprint: string, signedMessage: string | ArrayBuffer, messageHash: string) => Promise<string>;
|
|
22
lib/api/certificate/certificate.d.ts
vendored
22
lib/api/certificate/certificate.d.ts
vendored
@ -1,22 +0,0 @@
|
|||||||
import { TagTranslation } from '../../helpers/_parseCertInfo';
|
|
||||||
import { ExtendedKeysTranslations } from './getDecodedExtendedKeyUsage';
|
|
||||||
export declare type CadesCertificate = any;
|
|
||||||
export declare class Certificate {
|
|
||||||
_cadesCertificate: CadesCertificate;
|
|
||||||
name: string;
|
|
||||||
issuerName: string;
|
|
||||||
subjectName: string;
|
|
||||||
thumbprint: string;
|
|
||||||
validFrom: string;
|
|
||||||
validTo: string;
|
|
||||||
constructor(_cadesCertificate: CadesCertificate, name: string, issuerName: string, subjectName: string, thumbprint: string, validFrom: string, validTo: string);
|
|
||||||
getOwnerInfo(): Promise<TagTranslation[]>;
|
|
||||||
getIssuerInfo(): Promise<TagTranslation[]>;
|
|
||||||
getExtendedKeyUsage(): Promise<string[]>;
|
|
||||||
getDecodedExtendedKeyUsage(): Promise<ExtendedKeysTranslations>;
|
|
||||||
getAlgorithm(): Promise<string>;
|
|
||||||
getCadesProp(propName: any): Promise<any>;
|
|
||||||
isValid(): Promise<boolean>;
|
|
||||||
exportBase64(): Promise<string>;
|
|
||||||
hasExtendedKeyUsage(oids: any): Promise<boolean>;
|
|
||||||
}
|
|
6
lib/api/certificate/exportBase64.d.ts
vendored
6
lib/api/certificate/exportBase64.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Экспортирует сертификат в формате base64
|
|
||||||
*
|
|
||||||
* @returns сертификат в формате base64
|
|
||||||
*/
|
|
||||||
export declare const exportBase64: () => Promise<string>;
|
|
11
lib/api/certificate/getAlgorithm.d.ts
vendored
11
lib/api/certificate/getAlgorithm.d.ts
vendored
@ -1,11 +0,0 @@
|
|||||||
interface AlgorithmInfo {
|
|
||||||
algorithm: string;
|
|
||||||
oid: string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Возвращает информацию об алгоритме сертификата
|
|
||||||
*
|
|
||||||
* @returns информацию об алгоритме и его OID'е
|
|
||||||
*/
|
|
||||||
export declare const getAlgorithm: () => Promise<AlgorithmInfo>;
|
|
||||||
export {};
|
|
7
lib/api/certificate/getCadesProp.d.ts
vendored
7
lib/api/certificate/getCadesProp.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Возвращает указанное внутренее свойство у сертификата в формате Cades
|
|
||||||
*
|
|
||||||
* @param propName = наименование свойства
|
|
||||||
* @returns значение запрошенного свойства
|
|
||||||
*/
|
|
||||||
export declare const getCadesProp: (propName: string) => Promise<any>;
|
|
@ -1,9 +0,0 @@
|
|||||||
export interface ExtendedKeysTranslations {
|
|
||||||
[key: string]: string | null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Возвращает расшифрованные ОИД'ы сертификата
|
|
||||||
*
|
|
||||||
* @returns словарь расшифрованных ОИД'ов
|
|
||||||
*/
|
|
||||||
export declare const getDecodedExtendedKeyUsage: () => Promise<ExtendedKeysTranslations>;
|
|
6
lib/api/certificate/getExtendedKeyUsage.d.ts
vendored
6
lib/api/certificate/getExtendedKeyUsage.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Возвращает ОИД'ы сертификата
|
|
||||||
*
|
|
||||||
* @returns список ОИД'ов
|
|
||||||
*/
|
|
||||||
export declare const getExtendedKeyUsage: () => Promise<string[]>;
|
|
10
lib/api/certificate/getInfo.d.ts
vendored
10
lib/api/certificate/getInfo.d.ts
vendored
@ -1,10 +0,0 @@
|
|||||||
import { TagsTranslations } from '../../constants/tags-translations';
|
|
||||||
import { TagTranslation } from '../../helpers/_parseCertInfo';
|
|
||||||
/**
|
|
||||||
* Возвращает расшифрованную информацию о сертификате из указанного свойства по тэгам
|
|
||||||
*
|
|
||||||
* @param tags = словарь
|
|
||||||
* @param entitiesPath = путь к разбираемой сущности
|
|
||||||
* @returns расшифрованная информация по отдельным тэгам
|
|
||||||
*/
|
|
||||||
export declare const getInfo: (tags: TagsTranslations[], entitiesPath: string) => Promise<TagTranslation[]>;
|
|
7
lib/api/certificate/hasExtendedKeyUsage.d.ts
vendored
7
lib/api/certificate/hasExtendedKeyUsage.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Проверяет наличие ОИД'а (ОИД'ов) у сертификата
|
|
||||||
*
|
|
||||||
* @param oids - ОИД'ы для проверки
|
|
||||||
* @returns флаг наличия ОИД'ов у сертификата
|
|
||||||
*/
|
|
||||||
export declare const hasExtendedKeyUsage: (oids: string | string[]) => Promise<boolean>;
|
|
1
lib/api/certificate/index.d.ts
vendored
1
lib/api/certificate/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from './certificate';
|
|
6
lib/api/certificate/isValid.d.ts
vendored
6
lib/api/certificate/isValid.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Проверяет действительность сертификата
|
|
||||||
*
|
|
||||||
* @returns флаг валидности
|
|
||||||
*/
|
|
||||||
export declare const isValid: () => Promise<boolean>;
|
|
8
lib/api/createAttachedSignature.d.ts
vendored
8
lib/api/createAttachedSignature.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Создает присоединенную подпись сообщения по отпечатку сертификата
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @param message - подписываемое сообщение
|
|
||||||
* @returns подпись в формате PKCS#7
|
|
||||||
*/
|
|
||||||
export declare const createAttachedSignature: (thumbprint: string, unencryptedMessage: string | ArrayBuffer) => Promise<string>;
|
|
8
lib/api/createDetachedSignature.d.ts
vendored
8
lib/api/createDetachedSignature.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Создает отсоединенную подпись хеша по отпечатку сертификата
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @param messageHash - хеш подписываемого сообщения, сгенерированный по ГОСТ Р 34.11-2012 256 бит
|
|
||||||
* @returns подпись в формате PKCS#7
|
|
||||||
*/
|
|
||||||
export declare const createDetachedSignature: (thumbprint: string, messageHash: string) => Promise<string>;
|
|
9
lib/api/createHash.d.ts
vendored
9
lib/api/createHash.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* Создает хеш сообщения по ГОСТ Р 34.11-2012 256 бит
|
|
||||||
* https://ru.wikipedia.org/wiki/%D0%A1%D1%82%D1%80%D0%B8%D0%B1%D0%BE%D0%B3_(%D1%85%D0%B5%D1%88-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F)
|
|
||||||
*
|
|
||||||
* @param unencryptedMessage - сообщение для хеширования
|
|
||||||
*
|
|
||||||
* @returns хеш
|
|
||||||
*/
|
|
||||||
export declare const createHash: (unencryptedMessage: string | ArrayBuffer) => Promise<string>;
|
|
8
lib/api/createXMLSignature.d.ts
vendored
8
lib/api/createXMLSignature.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Создает XML подпись для документа в формате XML
|
|
||||||
*
|
|
||||||
* @param thumbprint - отпечаток сертификата
|
|
||||||
* @param unencryptedMessage - подписываемое сообщение в формате XML
|
|
||||||
* @returns подпись
|
|
||||||
*/
|
|
||||||
export declare const createXMLSignature: (thumbprint: string, unencryptedMessage: string) => Promise<string>;
|
|
8
lib/api/getAllCertificates.d.ts
vendored
8
lib/api/getAllCertificates.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Возвращает список сертификатов, доступных пользователю из пользовательского хранилища и закрытых ключей, не установленных в системе, без фильтрации по дате и наличию приватного ключа
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getAllCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
9
lib/api/getAllContainerCertificates.d.ts
vendored
9
lib/api/getAllContainerCertificates.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import { Certificate } from './certificate';
|
|
||||||
/**
|
|
||||||
* Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей
|
|
||||||
* Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа
|
|
||||||
*
|
|
||||||
* @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов
|
|
||||||
* @returns список сертификатов
|
|
||||||
*/
|
|
||||||
export declare const getAllContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>;
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user