@astral/features 3.93.0 → 3.93.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/styles.js +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/AutocompleteListItem.d.ts +13 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/AutocompleteListItem.js +24 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/styles.d.ts +684 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/styles.js +52 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/getShortFullName/getShortFullName.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/getShortFullName/getShortFullName.js +12 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/getShortFullName/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/getShortFullName/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/AutocompleteListItem/utils/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/CryptoProCertAutocomplete.d.ts +6 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/CryptoProCertAutocomplete.js +33 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/transformCertificates/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/transformCertificates/index.js +17 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/transformCertificates/transformCertificates.d.ts +12 -0
- package/node/cryproPro/components/CryptoProCertAutocomplete/utils/transformCertificates/transformCertificates.js +22 -0
- package/node/cryproPro/components/CryptoProCertFormAutocomplete/CryptoProCertFormAutocomplete.d.ts +7 -0
- package/node/cryproPro/components/CryptoProCertFormAutocomplete/CryptoProCertFormAutocomplete.js +15 -0
- package/node/cryproPro/components/CryptoProCertFormAutocomplete/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProCertFormAutocomplete/index.js +17 -0
- package/node/cryproPro/components/CryptoProProvider/CryptoProProvider.d.ts +14 -0
- package/node/cryproPro/components/CryptoProProvider/CryptoProProvider.js +17 -0
- package/node/cryproPro/components/CryptoProProvider/index.d.ts +1 -0
- package/node/cryproPro/components/CryptoProProvider/index.js +17 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/CryptoproviderInfo.d.ts +6 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/CryptoproviderInfo.js +29 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/index.d.ts +1 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/index.js +17 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/styles.d.ts +5 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/CryptoproviderInfo/styles.js +16 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/PluginInfo/PluginInfo.d.ts +6 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/PluginInfo/PluginInfo.js +15 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/PluginInfo/index.d.ts +1 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/PluginInfo/index.js +17 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/SetupCryptoProWorkspaceModal.d.ts +8 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/SetupCryptoProWorkspaceModal.js +16 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/index.d.ts +1 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/index.js +17 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/styles.d.ts +9 -0
- package/node/cryproPro/components/SetupCryptoProWorkspaceModal/styles.js +21 -0
- package/node/cryproPro/components/index.d.ts +4 -0
- package/node/cryproPro/components/index.js +20 -0
- package/node/cryproPro/constants/enums.d.ts +5 -0
- package/node/cryproPro/constants/enums.js +9 -0
- package/node/cryproPro/constants/error.d.ts +3 -0
- package/node/cryproPro/constants/error.js +6 -0
- package/node/cryproPro/constants/index.d.ts +2 -0
- package/node/cryproPro/constants/index.js +18 -0
- package/node/cryproPro/index.d.ts +3 -0
- package/node/cryproPro/index.js +12 -0
- package/node/cryproPro/services/CryptoProCertificateService/CryptoProCertificateService.d.ts +30 -0
- package/node/cryproPro/services/CryptoProCertificateService/CryptoProCertificateService.js +61 -0
- package/node/cryproPro/services/CryptoProCertificateService/index.d.ts +2 -0
- package/node/cryproPro/services/CryptoProCertificateService/index.js +18 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/convertBase64toBlob/convertBase64toBlob.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/convertBase64toBlob/convertBase64toBlob.js +7 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/convertBase64toBlob/index.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/convertBase64toBlob/index.js +17 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateExpiresDate/getCertificateExpiresDate.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateExpiresDate/getCertificateExpiresDate.js +10 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateExpiresDate/index.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateExpiresDate/index.js +17 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateOwnerShortName/getCertificateOwnerShortName.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateOwnerShortName/getCertificateOwnerShortName.js +15 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateOwnerShortName/index.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateOwnerShortName/index.js +17 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateType/getCertificateType.d.ts +2 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateType/getCertificateType.js +16 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateType/index.d.ts +1 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/getCertificateType/index.js +17 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/index.d.ts +4 -0
- package/node/cryproPro/services/CryptoProCertificateService/utils/index.js +20 -0
- package/node/cryproPro/services/CryptoProSignService/CryptoProSignService.d.ts +33 -0
- package/node/cryproPro/services/CryptoProSignService/CryptoProSignService.js +56 -0
- package/node/cryproPro/services/CryptoProSignService/index.d.ts +1 -0
- package/node/cryproPro/services/CryptoProSignService/index.js +17 -0
- package/node/cryproPro/services/WorkspaceSetupService/WorkspaceSetupService.d.ts +42 -0
- package/node/cryproPro/services/WorkspaceSetupService/WorkspaceSetupService.js +98 -0
- package/node/cryproPro/services/WorkspaceSetupService/index.d.ts +1 -0
- package/node/cryproPro/services/WorkspaceSetupService/index.js +17 -0
- package/node/cryproPro/services/index.d.ts +3 -0
- package/node/cryproPro/services/index.js +19 -0
- package/node/cryproPro/stores/CryptoProStore/CryptoProStore.d.ts +89 -0
- package/node/cryproPro/stores/CryptoProStore/CryptoProStore.js +139 -0
- package/node/cryproPro/stores/CryptoProStore/index.d.ts +1 -0
- package/node/cryproPro/stores/CryptoProStore/index.js +17 -0
- package/node/cryproPro/stores/index.d.ts +1 -0
- package/node/cryproPro/stores/index.js +17 -0
- package/node/cryproPro/types.d.ts +1 -0
- package/node/cryproPro/types.js +5 -0
- package/node/index.d.ts +2 -0
- package/node/index.js +21 -0
- package/node/productSwitcher/components/AstralProductSwitcher/AstralProductSwitcher.d.ts +12 -0
- package/node/productSwitcher/components/AstralProductSwitcher/AstralProductSwitcher.js +29 -0
- package/node/productSwitcher/components/AstralProductSwitcher/index.d.ts +1 -0
- package/node/productSwitcher/components/AstralProductSwitcher/index.js +17 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/IdentityProductSwitcher.d.ts +8 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/IdentityProductSwitcher.js +20 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/index.d.ts +1 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/index.js +5 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/index.d.ts +1 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/index.js +17 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/useLogic.d.ts +12 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/hooks/useLogic/useLogic.js +67 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/index.d.ts +1 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/index.js +17 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/styles.d.ts +22 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/styles.js +45 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/getIdentityTenants.d.ts +6 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/getIdentityTenants.js +25 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/index.d.ts +1 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getIdentityTenants/index.js +17 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/getTenantsProducts.d.ts +7 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/getTenantsProducts.js +28 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/index.d.ts +1 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/getTenantsProducts/index.js +17 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/index.d.ts +2 -0
- package/node/productSwitcher/components/IdentityProductSwitcher/utils/index.js +18 -0
- package/node/productSwitcher/components/index.d.ts +2 -0
- package/node/productSwitcher/components/index.js +18 -0
- package/node/productSwitcher/index.d.ts +1 -0
- package/node/productSwitcher/index.js +6 -0
- package/node/productSwitcher/types.d.ts +54 -0
- package/node/productSwitcher/types.js +2 -0
- package/node/productSwitcher/utils/formatIdentityProducts/formatIdentityProducts.d.ts +8 -0
- package/node/productSwitcher/utils/formatIdentityProducts/formatIdentityProducts.js +18 -0
- package/node/productSwitcher/utils/formatIdentityProducts/index.d.ts +1 -0
- package/node/productSwitcher/utils/formatIdentityProducts/index.js +17 -0
- package/node/productSwitcher/utils/getIdentityProducts/getIdentityProducts.d.ts +6 -0
- package/node/productSwitcher/utils/getIdentityProducts/getIdentityProducts.js +31 -0
- package/node/productSwitcher/utils/getIdentityProducts/index.d.ts +1 -0
- package/node/productSwitcher/utils/getIdentityProducts/index.js +17 -0
- package/node/productSwitcher/utils/index.d.ts +2 -0
- package/node/productSwitcher/utils/index.js +18 -0
- package/package.json +8 -4
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./WorkspaceSetupService"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CryptoProCertificateService"), exports);
|
|
18
|
+
__exportStar(require("./CryptoProSignService"), exports);
|
|
19
|
+
__exportStar(require("./WorkspaceSetupService"), exports);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type CADESCOM_XML_SIGNATURE_TYPE, type Certificate } from '@astral/cryptopro-cades';
|
|
2
|
+
import { type FormatedCertificate } from '../../services';
|
|
3
|
+
import { type CheckWorkspace } from '../../services/WorkspaceSetupService';
|
|
4
|
+
/**
|
|
5
|
+
* @description Стор для работы с сертификатами и выполнения криптоопераций. Является фасадом для сервисом КриптоПро
|
|
6
|
+
* */
|
|
7
|
+
export declare class CryptoProStore {
|
|
8
|
+
/**
|
|
9
|
+
* @description Флаг для открытия окна настройки рабочего места
|
|
10
|
+
* */
|
|
11
|
+
isRequestSetupWorkspace: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @description Флаг установки плагина
|
|
14
|
+
* */
|
|
15
|
+
isPluginInstalled: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @description Список сертификатов
|
|
18
|
+
* */
|
|
19
|
+
certificateList: Certificate[];
|
|
20
|
+
/**
|
|
21
|
+
* @description Список сертификатов приведенный к интерфейсу FormatedCertificate
|
|
22
|
+
* */
|
|
23
|
+
formatedCertificateList: FormatedCertificate[];
|
|
24
|
+
/**
|
|
25
|
+
* @description Сертификат, найденный по Skid
|
|
26
|
+
* */
|
|
27
|
+
certificateBySkid?: Certificate;
|
|
28
|
+
/**
|
|
29
|
+
* @description Информация о настройках рабочего места
|
|
30
|
+
* */
|
|
31
|
+
workspaceSetupInfo: CheckWorkspace;
|
|
32
|
+
private static instance;
|
|
33
|
+
private workspaceSetupService;
|
|
34
|
+
private cryptoProCertificateService;
|
|
35
|
+
private cryptoProSignService;
|
|
36
|
+
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* @description Метод проверки настройки рабочего места
|
|
39
|
+
* */
|
|
40
|
+
checkWorkspace: () => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* @description Метод сброса флага для открытия окна настройки рабочего места
|
|
43
|
+
* */
|
|
44
|
+
resetIsRequestSetupWorkspace: () => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* @description Метод получения списка сертификатов
|
|
47
|
+
* */
|
|
48
|
+
getCertificateList: () => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* @description Метод получения сертификата по skid
|
|
51
|
+
* */
|
|
52
|
+
getCertificateBySkid: (skid: string) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* @description Метод фильтрации списка сертификатов по ключам: subjectKeyId, innLe, inn
|
|
55
|
+
* */
|
|
56
|
+
filterCertificateList: (certificates: Certificate[], certificateSelectors?: string[]) => void;
|
|
57
|
+
/**
|
|
58
|
+
* @description Метод приведения списка сертификатов к интерфейсу FormatedCertificate
|
|
59
|
+
* * @param certificates список сертификатов
|
|
60
|
+
* */
|
|
61
|
+
formatCertificateList: (certificates: Certificate[]) => void;
|
|
62
|
+
/**
|
|
63
|
+
* @description Метод подписания в формате CMS
|
|
64
|
+
* @param certificate сертификат пользователя
|
|
65
|
+
* @param fileBuffer данные для подписания в виде массива байт либо в формате Base64 строки
|
|
66
|
+
* @param detach присоединять подпись к данным или отдельно?
|
|
67
|
+
* @param includeCertChain включать в результат всю цепочку?
|
|
68
|
+
* */
|
|
69
|
+
signCms: (certificate: Certificate, fileBuffer: ArrayBuffer, detach?: boolean, includeCertChain?: boolean) => Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* @description Метод подписания хэша указанным сертификатом в формате CMS
|
|
72
|
+
* @param certificate сертификат пользователя
|
|
73
|
+
* @param data данные для подписания в виде массива байт хэша либо сам хэш в формате hex строки (в любом регистре)
|
|
74
|
+
* * @param includeCertChain включать в результат всю цепочку?
|
|
75
|
+
* */
|
|
76
|
+
signHashCms: (certificate: Certificate, fileBuffer: ArrayBuffer, includeCertChain?: boolean) => Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* @description Метод подписания указанным сертификатом в формате XmlDSig
|
|
79
|
+
* @param certificate сертификат пользователя
|
|
80
|
+
* @param data данные для подписания в виде массива байт либо в формате Base64 строки
|
|
81
|
+
* @param xmlSignatureType тип xml подписи
|
|
82
|
+
* */
|
|
83
|
+
signXmlCms: (certificate: Certificate, fileBuffer: ArrayBuffer, xmlSignatureType: CADESCOM_XML_SIGNATURE_TYPE) => Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* @description Метод расшифровки данных
|
|
86
|
+
* @param encryptedData данные для расшифрования в виде массива байт либо в формате Base64 строки
|
|
87
|
+
* */
|
|
88
|
+
decryptCms: (fileBuffer: ArrayBuffer) => Promise<string>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CryptoProStore = void 0;
|
|
13
|
+
const mobx_1 = require("mobx");
|
|
14
|
+
const services_1 = require("../../services");
|
|
15
|
+
const WorkspaceSetupService_1 = require("../../services/WorkspaceSetupService");
|
|
16
|
+
/**
|
|
17
|
+
* @description Стор для работы с сертификатами и выполнения криптоопераций. Является фасадом для сервисом КриптоПро
|
|
18
|
+
* */
|
|
19
|
+
class CryptoProStore {
|
|
20
|
+
constructor() {
|
|
21
|
+
/**
|
|
22
|
+
* @description Флаг для открытия окна настройки рабочего места
|
|
23
|
+
* */
|
|
24
|
+
this.isRequestSetupWorkspace = false;
|
|
25
|
+
/**
|
|
26
|
+
* @description Флаг установки плагина
|
|
27
|
+
* */
|
|
28
|
+
this.isPluginInstalled = false;
|
|
29
|
+
/**
|
|
30
|
+
* @description Список сертификатов
|
|
31
|
+
* */
|
|
32
|
+
this.certificateList = [];
|
|
33
|
+
/**
|
|
34
|
+
* @description Список сертификатов приведенный к интерфейсу FormatedCertificate
|
|
35
|
+
* */
|
|
36
|
+
this.formatedCertificateList = [];
|
|
37
|
+
/**
|
|
38
|
+
* @description Сертификат, найденный по Skid
|
|
39
|
+
* */
|
|
40
|
+
this.certificateBySkid = {};
|
|
41
|
+
/**
|
|
42
|
+
* @description Информация о настройках рабочего места
|
|
43
|
+
* */
|
|
44
|
+
this.workspaceSetupInfo = {};
|
|
45
|
+
this.workspaceSetupService = {};
|
|
46
|
+
this.cryptoProCertificateService = {};
|
|
47
|
+
this.cryptoProSignService = {};
|
|
48
|
+
/**
|
|
49
|
+
* @description Метод проверки настройки рабочего места
|
|
50
|
+
* */
|
|
51
|
+
this.checkWorkspace = () => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
this.workspaceSetupInfo = yield this.workspaceSetupService
|
|
53
|
+
.checkWorkspace()
|
|
54
|
+
.finally(() => (this.isRequestSetupWorkspace = true));
|
|
55
|
+
this.isPluginInstalled = this.workspaceSetupInfo.isPluginInstalled;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* @description Метод сброса флага для открытия окна настройки рабочего места
|
|
59
|
+
* */
|
|
60
|
+
this.resetIsRequestSetupWorkspace = () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
this.isRequestSetupWorkspace = false;
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* @description Метод получения списка сертификатов
|
|
65
|
+
* */
|
|
66
|
+
this.getCertificateList = () => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
this.certificateList =
|
|
68
|
+
yield this.cryptoProCertificateService.getCertificateList();
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* @description Метод получения сертификата по skid
|
|
72
|
+
* */
|
|
73
|
+
this.getCertificateBySkid = (skid) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
this.certificateBySkid =
|
|
75
|
+
yield this.cryptoProCertificateService.getCertificateBySkid(skid);
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* @description Метод фильтрации списка сертификатов по ключам: subjectKeyId, innLe, inn
|
|
79
|
+
* */
|
|
80
|
+
this.filterCertificateList = (certificates, certificateSelectors) => {
|
|
81
|
+
this.certificateList =
|
|
82
|
+
this.cryptoProCertificateService.filterCertificateList(certificates, certificateSelectors);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @description Метод приведения списка сертификатов к интерфейсу FormatedCertificate
|
|
86
|
+
* * @param certificates список сертификатов
|
|
87
|
+
* */
|
|
88
|
+
this.formatCertificateList = (certificates) => {
|
|
89
|
+
this.formatedCertificateList =
|
|
90
|
+
this.cryptoProCertificateService.formatCertificateList(certificates);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @description Метод подписания в формате CMS
|
|
94
|
+
* @param certificate сертификат пользователя
|
|
95
|
+
* @param fileBuffer данные для подписания в виде массива байт либо в формате Base64 строки
|
|
96
|
+
* @param detach присоединять подпись к данным или отдельно?
|
|
97
|
+
* @param includeCertChain включать в результат всю цепочку?
|
|
98
|
+
* */
|
|
99
|
+
this.signCms = (certificate, fileBuffer, detach, includeCertChain) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
return this.cryptoProSignService.signCms(certificate, fileBuffer, detach, includeCertChain);
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* @description Метод подписания хэша указанным сертификатом в формате CMS
|
|
104
|
+
* @param certificate сертификат пользователя
|
|
105
|
+
* @param data данные для подписания в виде массива байт хэша либо сам хэш в формате hex строки (в любом регистре)
|
|
106
|
+
* * @param includeCertChain включать в результат всю цепочку?
|
|
107
|
+
* */
|
|
108
|
+
this.signHashCms = (certificate, fileBuffer, includeCertChain) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return this.cryptoProSignService.signHashCms(certificate, fileBuffer, includeCertChain);
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* @description Метод подписания указанным сертификатом в формате XmlDSig
|
|
113
|
+
* @param certificate сертификат пользователя
|
|
114
|
+
* @param data данные для подписания в виде массива байт либо в формате Base64 строки
|
|
115
|
+
* @param xmlSignatureType тип xml подписи
|
|
116
|
+
* */
|
|
117
|
+
this.signXmlCms = (certificate, fileBuffer, xmlSignatureType) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
return this.cryptoProSignService.signXmlCms(certificate, fileBuffer, xmlSignatureType);
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* @description Метод расшифровки данных
|
|
122
|
+
* @param encryptedData данные для расшифрования в виде массива байт либо в формате Base64 строки
|
|
123
|
+
* */
|
|
124
|
+
this.decryptCms = (fileBuffer) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
return this.cryptoProSignService.decryptCms(fileBuffer);
|
|
126
|
+
});
|
|
127
|
+
// делаем из класса singleton
|
|
128
|
+
if (CryptoProStore.instance) {
|
|
129
|
+
return CryptoProStore.instance;
|
|
130
|
+
}
|
|
131
|
+
CryptoProStore.instance = this;
|
|
132
|
+
this.workspaceSetupService = (0, WorkspaceSetupService_1.createWorkspaceSetupService)();
|
|
133
|
+
this.cryptoProCertificateService = new services_1.CryptoProCertificateService();
|
|
134
|
+
this.cryptoProSignService = new services_1.CryptoProSignService();
|
|
135
|
+
(0, mobx_1.makeAutoObservable)(this, {}, { autoBind: true });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.CryptoProStore = CryptoProStore;
|
|
139
|
+
CryptoProStore.instance = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CryptoProStore';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CryptoProStore"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CryptoProStore';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CryptoProStore"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Certificate } from '@astral/cryptopro-cades';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Certificate = void 0;
|
|
4
|
+
var cryptopro_cades_1 = require("@astral/cryptopro-cades");
|
|
5
|
+
Object.defineProperty(exports, "Certificate", { enumerable: true, get: function () { return cryptopro_cades_1.Certificate; } });
|
package/node/index.d.ts
ADDED
package/node/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AstralProductSwitcher = exports.IdentityProductSwitcher = void 0;
|
|
18
|
+
__exportStar(require("./cryproPro"), exports);
|
|
19
|
+
var productSwitcher_1 = require("./productSwitcher");
|
|
20
|
+
Object.defineProperty(exports, "IdentityProductSwitcher", { enumerable: true, get: function () { return productSwitcher_1.IdentityProductSwitcher; } });
|
|
21
|
+
Object.defineProperty(exports, "AstralProductSwitcher", { enumerable: true, get: function () { return productSwitcher_1.AstralProductSwitcher; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AstralProductSwitcherType = {
|
|
2
|
+
/**
|
|
3
|
+
* Адрес identity
|
|
4
|
+
* */
|
|
5
|
+
identityUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Идентификатор экосистемы
|
|
8
|
+
* @default astral
|
|
9
|
+
* */
|
|
10
|
+
tenantId?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const AstralProductSwitcher: ({ identityUrl, tenantId, }: AstralProductSwitcherType) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AstralProductSwitcher = void 0;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const ui_1 = require("@astral/ui");
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
const AstralProductSwitcher = ({ identityUrl, tenantId = 'astral', }) => {
|
|
18
|
+
const [products, setProducts] = (0, react_1.useState)([]);
|
|
19
|
+
const handleGetProducts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
if (!products.length) {
|
|
21
|
+
const productsList = yield (0, utils_1.getIdentityProducts)(identityUrl, tenantId);
|
|
22
|
+
setProducts(productsList);
|
|
23
|
+
return productsList;
|
|
24
|
+
}
|
|
25
|
+
return products;
|
|
26
|
+
});
|
|
27
|
+
return (0, jsx_runtime_1.jsx)(ui_1.ProductSwitcher, { getProducts: handleGetProducts });
|
|
28
|
+
};
|
|
29
|
+
exports.AstralProductSwitcher = AstralProductSwitcher;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AstralProductSwitcher';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AstralProductSwitcher"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const ASTRAL_IDENTITY_DEFAULT_TENANT = "astral";
|
|
2
|
+
export type IdentityProductSwitcherType = {
|
|
3
|
+
/**
|
|
4
|
+
* Адрес identity
|
|
5
|
+
* */
|
|
6
|
+
identityUrl: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const IdentityProductSwitcher: ({ identityUrl, }: IdentityProductSwitcherType) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdentityProductSwitcher = exports.ASTRAL_IDENTITY_DEFAULT_TENANT = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ui_1 = require("@astral/ui");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const hooks_1 = require("./hooks");
|
|
8
|
+
exports.ASTRAL_IDENTITY_DEFAULT_TENANT = 'astral';
|
|
9
|
+
const IdentityProductSwitcher = ({ identityUrl, }) => {
|
|
10
|
+
const { open, anchorRef, handleOpenMenu, handleCloseMenu } = (0, ui_1.useMenu)();
|
|
11
|
+
const { isLoading, isError, tenantId, tenants, productList, handleChangeTenant, handleShowProducts, } = (0, hooks_1.useLogic)(identityUrl, handleOpenMenu);
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.IconButton, { ref: anchorRef, selected: open, variant: "text", onClick: handleShowProducts, children: (0, jsx_runtime_1.jsx)(ui_1.ProductsFillMd, {}) }), (0, jsx_runtime_1.jsx)(styles_1.StyledMenu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, children: (0, jsx_runtime_1.jsx)(ui_1.MenuGroup, { label: "\u041F\u0440\u043E\u0434\u0443\u043A\u0442\u044B \u044D\u043A\u043E\u0441\u0438\u0441\u0442\u0435\u043C\u044B", children: (0, jsx_runtime_1.jsxs)(ui_1.ContentState, { isLoading: isLoading, isCustom: isError, customState: {
|
|
13
|
+
imgAlt: 'Что-то пошло не так',
|
|
14
|
+
title: ((0, jsx_runtime_1.jsxs)(styles_1.ErrorContainer, { container: true, autoFlow: "column", alignItems: "center", justifyContent: "center", component: "span", children: [(0, jsx_runtime_1.jsx)(ui_1.ErrorFillSm, { color: "inherit" }), (0, jsx_runtime_1.jsx)(ui_1.Typography, { variant: "h6", color: "grey", colorIntensity: "900", children: "\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A" })] })),
|
|
15
|
+
description: 'Произошла ошибка. Повторите попытку позже.',
|
|
16
|
+
}, children: [Boolean(tenants === null || tenants === void 0 ? void 0 : tenants.length) && ((0, jsx_runtime_1.jsx)(styles_1.TenantsToggleButtonGroup, { exclusive: true, onChange: handleChangeTenant, value: tenantId, children: tenants === null || tenants === void 0 ? void 0 : tenants.map(({ id, name }) => ((0, jsx_runtime_1.jsx)(styles_1.TenantToggleButton, { value: id, children: name }, id))) })), productList === null || productList === void 0 ? void 0 : productList.map((product) => {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsxs)(styles_1.StyledMenuItem, { component: "a", href: product.url, children: [(0, jsx_runtime_1.jsx)(styles_1.Logo, { src: product.logoUrl, color: product.color }), (0, jsx_runtime_1.jsx)(ui_1.Typography, { variant: "ui", color: "grey", colorIntensity: "900", children: product.name })] }) }, product.id));
|
|
18
|
+
})] }) }) })] }));
|
|
19
|
+
};
|
|
20
|
+
exports.IdentityProductSwitcher = IdentityProductSwitcher;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLogic } from './useLogic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useLogic"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MouseEvent } from 'react';
|
|
2
|
+
import { type WidgetProduct } from '@astral/ui';
|
|
3
|
+
import { type IdentityTenantsDTO } from '../../../../types';
|
|
4
|
+
export declare const useLogic: (identityUrl: string, openMenu: () => void) => {
|
|
5
|
+
handleShowProducts: () => void;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isError: boolean;
|
|
8
|
+
tenants: IdentityTenantsDTO[] | undefined;
|
|
9
|
+
handleChangeTenant: (_event: MouseEvent<HTMLElement>, selectedValue: string) => void;
|
|
10
|
+
tenantId: string;
|
|
11
|
+
productList: WidgetProduct[] | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useLogic = void 0;
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const ui_1 = require("@astral/ui");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
const IdentityProductSwitcher_1 = require("../../IdentityProductSwitcher");
|
|
17
|
+
const useLogic = (identityUrl, openMenu) => {
|
|
18
|
+
const { captureException } = (0, react_1.useContext)(ui_1.ConfigContext);
|
|
19
|
+
const [tenantsProductsMap, setTenantsProductsMap] = (0, react_1.useState)();
|
|
20
|
+
const [tenants, setTenants] = (0, react_1.useState)();
|
|
21
|
+
const [tenantId, setTenantId] = (0, react_1.useState)(IdentityProductSwitcher_1.ASTRAL_IDENTITY_DEFAULT_TENANT);
|
|
22
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
23
|
+
const [isError, setIsError] = (0, react_1.useState)(false);
|
|
24
|
+
const productList = (0, react_1.useMemo)(() => tenantsProductsMap === null || tenantsProductsMap === void 0 ? void 0 : tenantsProductsMap[tenantId], [tenantsProductsMap, tenantId]);
|
|
25
|
+
const loadProducts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const tenantsInfo = yield (0, utils_1.getIdentityTenants)(identityUrl);
|
|
28
|
+
const tenantsIds = tenantsInfo.map(({ id }) => id);
|
|
29
|
+
const tenantsProducts = yield (0, utils_1.getTenantsProducts)(identityUrl, tenantsIds);
|
|
30
|
+
if (tenantsIds[0] !== tenantId) {
|
|
31
|
+
setTenantId(tenantsIds[0]);
|
|
32
|
+
}
|
|
33
|
+
setTenants(tenantsInfo);
|
|
34
|
+
setTenantsProductsMap(tenantsProducts);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
setIsError(true);
|
|
38
|
+
captureException(error);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
setIsLoading(false);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const handleShowProducts = () => {
|
|
45
|
+
setIsError(false);
|
|
46
|
+
openMenu();
|
|
47
|
+
if (!tenantsProductsMap) {
|
|
48
|
+
setIsLoading(true);
|
|
49
|
+
loadProducts().then();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleChangeTenant = (_event, selectedValue) => {
|
|
53
|
+
if (selectedValue) {
|
|
54
|
+
setTenantId(selectedValue);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
handleShowProducts,
|
|
59
|
+
isLoading,
|
|
60
|
+
isError,
|
|
61
|
+
tenants,
|
|
62
|
+
handleChangeTenant,
|
|
63
|
+
tenantId,
|
|
64
|
+
productList,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.useLogic = useLogic;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IdentityProductSwitcher';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IdentityProductSwitcher"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledMenu: import("@emotion/styled").StyledComponent<import("@astral/ui").WithoutEmotionSpecific<import("@mui/material").MenuProps> & {
|
|
3
|
+
title?: string | undefined;
|
|
4
|
+
} & {
|
|
5
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
6
|
+
}, {}, {}>;
|
|
7
|
+
export declare const StyledMenuItem: import("@mui/material").ExtendButtonBase<import("@mui/material").MenuItemTypeMap<{}, "li">>;
|
|
8
|
+
export declare const Logo: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
11
|
+
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
12
|
+
export declare const ErrorContainer: import("@emotion/styled").StyledComponent<import("@astral/ui").GridContainerProps & import("@astral/ui").GridElementsProps & {
|
|
13
|
+
children?: import("react").ReactNode;
|
|
14
|
+
} & import("react").RefAttributes<HTMLElement> & {
|
|
15
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
16
|
+
}, {}, {}>;
|
|
17
|
+
export declare const TenantsToggleButtonGroup: import("@emotion/styled").StyledComponent<Omit<import("@astral/ui").ToggleButtonGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
}, {}, {}>;
|
|
20
|
+
export declare const TenantToggleButton: import("@emotion/styled").StyledComponent<Omit<import("@astral/ui").ToggleButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement> & {
|
|
21
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
22
|
+
}, {}, {}>;
|