@icure/api 8.0.64 → 8.0.65

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.
Files changed (129) hide show
  1. package/icc-api/api/internal/IccExchangeDataApi.d.ts +2 -0
  2. package/icc-api/api/internal/IccExchangeDataApi.js +10 -0
  3. package/icc-api/api/internal/IccExchangeDataApi.js.map +1 -1
  4. package/icc-api/iccApi.d.ts +0 -1
  5. package/icc-api/iccApi.js +0 -1
  6. package/icc-api/iccApi.js.map +1 -1
  7. package/icc-api/index.d.ts +0 -1
  8. package/icc-api/index.js +0 -1
  9. package/icc-api/index.js.map +1 -1
  10. package/icc-x-api/crypto/AccessControlSecretUtils.d.ts +4 -13
  11. package/icc-x-api/crypto/AccessControlSecretUtils.js +19 -29
  12. package/icc-x-api/crypto/AccessControlSecretUtils.js.map +1 -1
  13. package/icc-x-api/crypto/BaseExchangeDataManager.d.ts +6 -2
  14. package/icc-x-api/crypto/BaseExchangeDataManager.js +26 -9
  15. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  16. package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +2 -3
  17. package/icc-x-api/crypto/BaseExchangeKeysManager.js +8 -16
  18. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
  19. package/icc-x-api/crypto/CryptoPrimitives.d.ts +2 -0
  20. package/icc-x-api/crypto/CryptoPrimitives.js +3 -0
  21. package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -1
  22. package/icc-x-api/crypto/DelegationsDeAnonymization.d.ts +3 -3
  23. package/icc-x-api/crypto/DelegationsDeAnonymization.js +7 -7
  24. package/icc-x-api/crypto/DelegationsDeAnonymization.js.map +1 -1
  25. package/icc-x-api/crypto/ExchangeDataManager.d.ts +19 -29
  26. package/icc-x-api/crypto/ExchangeDataManager.js +200 -225
  27. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  28. package/icc-x-api/crypto/ExchangeDataMapManager.js +6 -4
  29. package/icc-x-api/crypto/ExchangeDataMapManager.js.map +1 -1
  30. package/icc-x-api/crypto/ExchangeKeysManager.d.ts +4 -16
  31. package/icc-x-api/crypto/ExchangeKeysManager.js +44 -41
  32. package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
  33. package/icc-x-api/crypto/ExtendedApisUtils.d.ts +47 -25
  34. package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
  35. package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +19 -18
  36. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +213 -134
  37. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  38. package/icc-x-api/crypto/HMACUtils.d.ts +2 -2
  39. package/icc-x-api/crypto/HMACUtils.js +3 -4
  40. package/icc-x-api/crypto/HMACUtils.js.map +1 -1
  41. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.d.ts +1 -0
  42. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js +5 -0
  43. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js.map +1 -1
  44. package/icc-x-api/crypto/SecureDelegationsManager.d.ts +0 -1
  45. package/icc-x-api/crypto/SecureDelegationsManager.js +17 -49
  46. package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
  47. package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +59 -90
  48. package/icc-x-api/crypto/SecurityMetadataDecryptor.js +470 -56
  49. package/icc-x-api/crypto/SecurityMetadataDecryptor.js.map +1 -1
  50. package/icc-x-api/crypto/ShamirKeysManager.js +1 -1
  51. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
  52. package/icc-x-api/crypto/TransferKeysManager.d.ts +1 -3
  53. package/icc-x-api/crypto/TransferKeysManager.js +2 -4
  54. package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
  55. package/icc-x-api/icc-accesslog-x-api.d.ts +2 -2
  56. package/icc-x-api/icc-accesslog-x-api.js +7 -3
  57. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  58. package/icc-x-api/icc-calendar-item-x-api.js +4 -2
  59. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  60. package/icc-x-api/icc-contact-x-api.d.ts +0 -1
  61. package/icc-x-api/icc-contact-x-api.js +33 -48
  62. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  63. package/icc-x-api/icc-crypto-x-api.js +1 -1
  64. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  65. package/icc-x-api/icc-document-x-api.d.ts +2 -2
  66. package/icc-x-api/icc-document-x-api.js +45 -42
  67. package/icc-x-api/icc-document-x-api.js.map +1 -1
  68. package/icc-x-api/icc-form-x-api.js +3 -1
  69. package/icc-x-api/icc-form-x-api.js.map +1 -1
  70. package/icc-x-api/icc-helement-x-api.js +4 -4
  71. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  72. package/icc-x-api/icc-maintenance-task-x-api.js +4 -2
  73. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  74. package/icc-x-api/icc-message-x-api.js +4 -2
  75. package/icc-x-api/icc-message-x-api.js.map +1 -1
  76. package/icc-x-api/icc-patient-x-api.js +5 -7
  77. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  78. package/icc-x-api/icc-topic-x-api.js +2 -2
  79. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  80. package/icc-x-api/index.d.ts +1 -2
  81. package/icc-x-api/index.js +7 -13
  82. package/icc-x-api/index.js.map +1 -1
  83. package/icc-x-api/utils/crypto-utils.d.ts +6 -4
  84. package/icc-x-api/utils/crypto-utils.js +27 -6
  85. package/icc-x-api/utils/crypto-utils.js.map +1 -1
  86. package/icc-x-api/utils/simple-lru-cache.d.ts +19 -0
  87. package/icc-x-api/utils/simple-lru-cache.js +90 -0
  88. package/icc-x-api/utils/simple-lru-cache.js.map +1 -0
  89. package/package.json +4 -2
  90. package/test/icc-x-api/crud/entities-crud-test-interface.js +0 -8
  91. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -1
  92. package/test/icc-x-api/crypto/exchange-data-manager-test.js +74 -92
  93. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -1
  94. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +1 -1
  95. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +27 -15
  96. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -1
  97. package/test/utils/FakeEncryptionKeysManager.d.ts +1 -0
  98. package/test/utils/FakeEncryptionKeysManager.js +11 -0
  99. package/test/utils/FakeEncryptionKeysManager.js.map +1 -1
  100. package/test/utils/FakeExchangeDataApi.d.ts +4 -2
  101. package/test/utils/FakeExchangeDataApi.js +24 -6
  102. package/test/utils/FakeExchangeDataApi.js.map +1 -1
  103. package/test/utils/FakeExchangeDataManager.d.ts +10 -10
  104. package/test/utils/FakeExchangeDataManager.js +12 -22
  105. package/test/utils/FakeExchangeDataManager.js.map +1 -1
  106. package/icc-api/api/IccArticleApi.d.ts +0 -72
  107. package/icc-api/api/IccArticleApi.js +0 -149
  108. package/icc-api/api/IccArticleApi.js.map +0 -1
  109. package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.d.ts +0 -33
  110. package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.js +0 -141
  111. package/icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.js.map +0 -1
  112. package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.d.ts +0 -46
  113. package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js +0 -312
  114. package/icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor.js.map +0 -1
  115. package/icc-x-api/crypto/UserSignatureKeysManager.d.ts +0 -26
  116. package/icc-x-api/crypto/UserSignatureKeysManager.js +0 -78
  117. package/icc-x-api/crypto/UserSignatureKeysManager.js.map +0 -1
  118. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.d.ts +0 -1
  119. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js +0 -393
  120. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js.map +0 -1
  121. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.d.ts +0 -1
  122. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js +0 -213
  123. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js.map +0 -1
  124. package/test/icc-x-api/crypto/signature-keys-manager-test.d.ts +0 -1
  125. package/test/icc-x-api/crypto/signature-keys-manager-test.js +0 -44
  126. package/test/icc-x-api/crypto/signature-keys-manager-test.js.map +0 -1
  127. package/test/utils/FakeSignatureKeysManager.d.ts +0 -16
  128. package/test/utils/FakeSignatureKeysManager.js +0 -54
  129. package/test/utils/FakeSignatureKeysManager.js.map +0 -1
@@ -1,72 +0,0 @@
1
- /**
2
- * iCure Data Stack API Documentation
3
- * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
4
- *
5
- * OpenAPI spec version: v1
6
- *
7
- *
8
- * NOTE: This class is auto generated by the swagger code generator program.
9
- * https://github.com/swagger-api/swagger-codegen.git
10
- * Do not edit the class manually.
11
- */
12
- import { XHR } from './XHR';
13
- import { Article } from '../model/Article';
14
- import { DocIdentifier } from '../model/DocIdentifier';
15
- import { AuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider';
16
- import { ListOfIds } from '../model/ListOfIds';
17
- import { PaginatedListArticle } from '../model/PaginatedListArticle';
18
- export declare class IccArticleApi {
19
- host: string;
20
- headers: Array<XHR.Header>;
21
- authenticationProvider: AuthenticationProvider;
22
- fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
23
- constructor(host: string, headers: any, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
24
- setHeaders(h: Array<XHR.Header>): void;
25
- handleError(e: XHR.XHRError): never;
26
- /**
27
- *
28
- * @summary Creates a article
29
- * @param body
30
- */
31
- createArticle(body?: Article): Promise<Article>;
32
- /**
33
- * @summary Deletes a batch of articles by id.
34
- *
35
- * @param articleIds a ListOfIds containing the ids of the articles to delete.
36
- * @return a Promise that will resolve in an array of DocIdentifiers of the successfully delete articles.
37
- */
38
- deleteArticles(articleIds: ListOfIds): Promise<Array<DocIdentifier>>;
39
- /**
40
- * @summary Deletes a single article by id.
41
- *
42
- * @param articleId the id of the article to delete.
43
- * @return a Promise that will resolve in the DocIdentifier of the deleted article.
44
- */
45
- deleteArticle(articleId: string): Promise<DocIdentifier>;
46
- /**
47
- *
48
- * @summary Gets an article
49
- * @param articleId
50
- */
51
- getArticle(articleId: string): Promise<Article>;
52
- /**
53
- * @deprecated use {@link getArticlesWithPagination} instead.
54
- *
55
- * @summary Gets all articles
56
- */
57
- getArticles(): Promise<Array<Article>>;
58
- /**
59
- * @summary gets all articles with pagination.
60
- *
61
- * @param startDocumentId the startDocumentId provided by the previous page or null if it's the first page.
62
- * @param limit the size of the page
63
- * @return a promise that will resolve in a PaginatedListArticle.
64
- */
65
- getArticlesWithPagination(startDocumentId?: string, limit?: number): Promise<PaginatedListArticle>;
66
- /**
67
- *
68
- * @summary Modifies an article
69
- * @param body
70
- */
71
- modifyArticle(body?: Article): Promise<Article>;
72
- }
@@ -1,149 +0,0 @@
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.IccArticleApi = void 0;
13
- /**
14
- * iCure Data Stack API Documentation
15
- * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
16
- *
17
- * OpenAPI spec version: v1
18
- *
19
- *
20
- * NOTE: This class is auto generated by the swagger code generator program.
21
- * https://github.com/swagger-api/swagger-codegen.git
22
- * Do not edit the class manually.
23
- */
24
- const XHR_1 = require("./XHR");
25
- const Article_1 = require("../model/Article");
26
- const DocIdentifier_1 = require("../model/DocIdentifier");
27
- const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
28
- const IccRestApiPath_1 = require("./IccRestApiPath");
29
- const PaginatedListArticle_1 = require("../model/PaginatedListArticle");
30
- class IccArticleApi {
31
- constructor(host, headers, authenticationProvider, fetchImpl) {
32
- this.host = (0, IccRestApiPath_1.iccRestApiPath)(host);
33
- this.headers = Object.keys(headers).map((k) => new XHR_1.XHR.Header(k, headers[k]));
34
- this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new AuthenticationProvider_1.NoAuthenticationProvider();
35
- this.fetchImpl = fetchImpl;
36
- }
37
- setHeaders(h) {
38
- this.headers = h;
39
- }
40
- handleError(e) {
41
- throw e;
42
- }
43
- /**
44
- *
45
- * @summary Creates a article
46
- * @param body
47
- */
48
- createArticle(body) {
49
- const _url = this.host + `/article` + '?ts=' + new Date().getTime();
50
- let headers = this.headers;
51
- headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
52
- return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
53
- .then((doc) => new Article_1.Article(doc.body))
54
- .catch((err) => this.handleError(err));
55
- }
56
- /**
57
- * @summary Deletes a batch of articles by id.
58
- *
59
- * @param articleIds a ListOfIds containing the ids of the articles to delete.
60
- * @return a Promise that will resolve in an array of DocIdentifiers of the successfully delete articles.
61
- */
62
- deleteArticles(articleIds) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- return XHR_1.XHR.sendCommand('POST', this.host + `/article/delete/batch` + '?ts=' + new Date().getTime(), this.headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json')), articleIds, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
65
- .then((doc) => doc.body.map((it) => new DocIdentifier_1.DocIdentifier(it)))
66
- .catch((err) => this.handleError(err));
67
- });
68
- }
69
- /**
70
- * @summary Deletes a single article by id.
71
- *
72
- * @param articleId the id of the article to delete.
73
- * @return a Promise that will resolve in the DocIdentifier of the deleted article.
74
- */
75
- deleteArticle(articleId) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- return XHR_1.XHR.sendCommand('DELETE', this.host + `/article/${encodeURIComponent(articleId)}` + '?ts=' + new Date().getTime(), this.headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
78
- .then((doc) => new DocIdentifier_1.DocIdentifier(doc.body))
79
- .catch((err) => this.handleError(err));
80
- });
81
- }
82
- /**
83
- *
84
- * @summary Gets an article
85
- * @param articleId
86
- */
87
- getArticle(articleId) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- let _body = null;
90
- const _url = this.host + `/article/${encodeURIComponent(String(articleId))}` + '?ts=' + new Date().getTime();
91
- let headers = this.headers;
92
- return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
93
- .then((doc) => new Article_1.Article(doc.body))
94
- .catch((err) => this.handleError(err));
95
- });
96
- }
97
- /**
98
- * @deprecated use {@link getArticlesWithPagination} instead.
99
- *
100
- * @summary Gets all articles
101
- */
102
- getArticles() {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const _url = this.host + `/article` + '?ts=' + new Date().getTime() + '&limit=1000000';
105
- let headers = this.headers;
106
- return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
107
- .then((doc) => { var _a; return (_a = new PaginatedListArticle_1.PaginatedListArticle(doc.body).rows) !== null && _a !== void 0 ? _a : []; })
108
- .catch((err) => this.handleError(err));
109
- });
110
- }
111
- /**
112
- * @summary gets all articles with pagination.
113
- *
114
- * @param startDocumentId the startDocumentId provided by the previous page or null if it's the first page.
115
- * @param limit the size of the page
116
- * @return a promise that will resolve in a PaginatedListArticle.
117
- */
118
- getArticlesWithPagination(startDocumentId, limit) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const _url = this.host +
121
- `/article` +
122
- '?ts=' +
123
- new Date().getTime() +
124
- (!!startDocumentId ? `&startDocumentId=${encodeURIComponent(startDocumentId)}` : '') +
125
- (!!limit ? `&limit=${limit}` : '');
126
- let headers = this.headers;
127
- return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
128
- .then((doc) => new PaginatedListArticle_1.PaginatedListArticle(doc.body))
129
- .catch((err) => this.handleError(err));
130
- });
131
- }
132
- /**
133
- *
134
- * @summary Modifies an article
135
- * @param body
136
- */
137
- modifyArticle(body) {
138
- let _body = null;
139
- _body = body;
140
- const _url = this.host + `/article` + '?ts=' + new Date().getTime();
141
- let headers = this.headers;
142
- headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
143
- return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
144
- .then((doc) => new Article_1.Article(doc.body))
145
- .catch((err) => this.handleError(err));
146
- }
147
- }
148
- exports.IccArticleApi = IccArticleApi;
149
- //# sourceMappingURL=IccArticleApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IccArticleApi.js","sourceRoot":"","sources":["../../../icc-api/api/IccArticleApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,+BAA2B;AAC3B,8CAA0C;AAC1C,0DAAsD;AACtD,wFAA8G;AAC9G,qDAAiD;AAEjD,wEAAoE;AAEpE,MAAa,aAAa;IAMxB,YACE,IAAY,EACZ,OAAY,EACZ,sBAA+C,EAC/C,SAAyE;QAEzE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AG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QACnE,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,MAAM,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAA;QACvH,OAAO,SAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;aACzH,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,GAAG,CAAC,IAAY,CAAC,CAAC;aAC5C,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACF;AAjJD,sCAiJC","sourcesContent":["/**\n * iCure Data Stack API Documentation\n * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.\n *\n * OpenAPI spec version: v1\n *\n *\n * NOTE: This class is auto generated by the swagger code generator program.\n * https://github.com/swagger-api/swagger-codegen.git\n * Do not edit the class manually.\n */\nimport { XHR } from './XHR'\nimport { Article } from '../model/Article'\nimport { DocIdentifier } from '../model/DocIdentifier'\nimport { AuthenticationProvider, NoAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { iccRestApiPath } from './IccRestApiPath'\nimport { ListOfIds } from '../model/ListOfIds'\nimport { PaginatedListArticle } from '../model/PaginatedListArticle'\n\nexport class IccArticleApi {\n host: string\n headers: Array<XHR.Header>\n authenticationProvider: AuthenticationProvider\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n constructor(\n host: string,\n headers: any,\n authenticationProvider?: AuthenticationProvider,\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n ) {\n this.host = iccRestApiPath(host)\n this.headers = Object.keys(headers).map((k) => new XHR.Header(k, headers[k]))\n this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new NoAuthenticationProvider()\n this.fetchImpl = fetchImpl\n }\n\n setHeaders(h: Array<XHR.Header>) {\n this.headers = h\n }\n\n handleError(e: XHR.XHRError): never {\n throw e\n }\n\n /**\n *\n * @summary Creates a article\n * @param body\n */\n createArticle(body?: Article): Promise<Article> {\n const _url = this.host + `/article` + '?ts=' + new Date().getTime()\n let headers = this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Article(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a batch of articles by id.\n *\n * @param articleIds a ListOfIds containing the ids of the articles to delete.\n * @return a Promise that will resolve in an array of DocIdentifiers of the successfully delete articles.\n */\n async deleteArticles(articleIds: ListOfIds): Promise<Array<DocIdentifier>> {\n return XHR.sendCommand(\n 'POST',\n this.host + `/article/delete/batch` + '?ts=' + new Date().getTime(),\n this.headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json')),\n articleIds,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => (doc.body as Array<JSON>).map((it) => new DocIdentifier(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary Deletes a single article by id.\n *\n * @param articleId the id of the article to delete.\n * @return a Promise that will resolve in the DocIdentifier of the deleted article.\n */\n async deleteArticle(articleId: string): Promise<DocIdentifier> {\n return XHR.sendCommand(\n 'DELETE',\n this.host + `/article/${encodeURIComponent(articleId)}` + '?ts=' + new Date().getTime(),\n this.headers,\n null,\n this.fetchImpl,\n undefined,\n this.authenticationProvider.getAuthService()\n )\n .then((doc) => new DocIdentifier(doc.body))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Gets an article\n * @param articleId\n */\n async getArticle(articleId: string): Promise<Article> {\n let _body = null\n\n const _url = this.host + `/article/${encodeURIComponent(String(articleId))}` + '?ts=' + new Date().getTime()\n let headers = this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Article(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @deprecated use {@link getArticlesWithPagination} instead.\n *\n * @summary Gets all articles\n */\n async getArticles(): Promise<Array<Article>> {\n const _url = this.host + `/article` + '?ts=' + new Date().getTime() + '&limit=1000000'\n let headers = this.headers\n return XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListArticle(doc.body as JSON).rows ?? [])\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @summary gets all articles with pagination.\n *\n * @param startDocumentId the startDocumentId provided by the previous page or null if it's the first page.\n * @param limit the size of the page\n * @return a promise that will resolve in a PaginatedListArticle.\n */\n async getArticlesWithPagination(startDocumentId?: string, limit?: number): Promise<PaginatedListArticle> {\n const _url =\n this.host +\n `/article` +\n '?ts=' +\n new Date().getTime() +\n (!!startDocumentId ? `&startDocumentId=${encodeURIComponent(startDocumentId)}` : '') +\n (!!limit ? `&limit=${limit}` : '')\n let headers = this.headers\n return XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new PaginatedListArticle(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Modifies an article\n * @param body\n */\n modifyArticle(body?: Article): Promise<Article> {\n let _body = null\n _body = body\n\n const _url = this.host + `/article` + '?ts=' + new Date().getTime()\n let headers = this.headers\n headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR.Header('Content-Type', 'application/json'))\n return XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => new Article(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n}\n"]}
@@ -1,33 +0,0 @@
1
- import { SecurityMetadataDecryptor } from './SecurityMetadataDecryptor';
2
- import { EncryptedEntityWithType } from '../utils/EntityWithDelegationTypeName';
3
- import { CryptoPrimitives } from './CryptoPrimitives';
4
- import { ExchangeKeysManager } from './ExchangeKeysManager';
5
- import { SecureDelegation } from '../../icc-api/model/SecureDelegation';
6
- import AccessLevel = SecureDelegation.AccessLevelEnum;
7
- import { EncryptedEntity, EncryptedEntityStub } from '../../icc-api/model/models';
8
- export declare class LegacyDelegationSecurityMetadataDecryptor implements SecurityMetadataDecryptor {
9
- private readonly exchangeKeysManager;
10
- private readonly primitives;
11
- constructor(exchangeKeysManager: ExchangeKeysManager, primitives: CryptoPrimitives);
12
- decryptEncryptionKeysOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
13
- decrypted: string;
14
- dataOwnersWithAccess: string[];
15
- }, void, never>;
16
- decryptOwningEntityIdsOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
17
- decrypted: string;
18
- dataOwnersWithAccess: string[];
19
- }, void, never>;
20
- decryptSecretIdsOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
21
- decrypted: string;
22
- dataOwnersWithAccess: string[];
23
- }, void, never>;
24
- getEntityAccessLevel(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): Promise<AccessLevel | undefined>;
25
- hasAnyEncryptionKeys(entity: EncryptedEntity | EncryptedEntityStub): boolean;
26
- private extractFromDelegations;
27
- private populateDelegatedTo;
28
- private tryDecryptDelegation;
29
- private validateEncryptionKey;
30
- private validateSecretId;
31
- private validateOwningEntityId;
32
- private tryImportKey;
33
- }
@@ -1,141 +0,0 @@
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
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
16
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
17
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
18
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
19
- function fulfill(value) { resume("next", value); }
20
- function reject(value) { resume("throw", value); }
21
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.LegacyDelegationSecurityMetadataDecryptor = void 0;
25
- const ModelHelper_1 = require("../../icc-api/model/ModelHelper");
26
- const utils_1 = require("../utils");
27
- const SecureDelegation_1 = require("../../icc-api/model/SecureDelegation");
28
- var AccessLevel = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
29
- class LegacyDelegationSecurityMetadataDecryptor {
30
- constructor(exchangeKeysManager, primitives) {
31
- this.exchangeKeysManager = exchangeKeysManager;
32
- this.primitives = primitives;
33
- }
34
- decryptEncryptionKeysOf(typedEntity, dataOwnersHierarchySubset) {
35
- function generator(self) {
36
- var _a;
37
- return __asyncGenerator(this, arguments, function* generator_1() {
38
- const decryptedGenerator = self.extractFromDelegations(dataOwnersHierarchySubset, (_a = typedEntity.entity.encryptionKeys) !== null && _a !== void 0 ? _a : {}, (d) => self.validateEncryptionKey(d));
39
- let next = yield __await(decryptedGenerator.next());
40
- while (!next.done) {
41
- yield yield __await({ decrypted: next.value.decrypted.replace(/-/g, ''), dataOwnersWithAccess: next.value.dataOwnersWithAccess });
42
- next = yield __await(decryptedGenerator.next());
43
- }
44
- });
45
- }
46
- return generator(this);
47
- }
48
- decryptOwningEntityIdsOf(typedEntity, dataOwnersHierarchySubset) {
49
- var _a;
50
- return this.extractFromDelegations(dataOwnersHierarchySubset, (_a = typedEntity.entity.cryptedForeignKeys) !== null && _a !== void 0 ? _a : {}, (d) => Promise.resolve(this.validateOwningEntityId(d)));
51
- }
52
- decryptSecretIdsOf(typedEntity, dataOwnersHierarchySubset) {
53
- var _a;
54
- return this.extractFromDelegations(dataOwnersHierarchySubset, (_a = typedEntity.entity.delegations) !== null && _a !== void 0 ? _a : {}, (d) => Promise.resolve(this.validateSecretId(d)));
55
- }
56
- getEntityAccessLevel(typedEntity, dataOwnersHierarchySubset) {
57
- var _a;
58
- const delegatesSet = new Set(Object.keys((_a = typedEntity.entity.delegations) !== null && _a !== void 0 ? _a : {}));
59
- return dataOwnersHierarchySubset.some((dataOwner) => delegatesSet.has(dataOwner))
60
- ? Promise.resolve(AccessLevel.WRITE)
61
- : Promise.resolve(undefined);
62
- }
63
- hasAnyEncryptionKeys(entity) {
64
- var _a;
65
- return Object.values((_a = entity.encryptionKeys) !== null && _a !== void 0 ? _a : {}).some((delegations) => delegations.length > 0);
66
- }
67
- extractFromDelegations(dataOwnersHierarchySubset, delegations, validateDecrypted) {
68
- if (!dataOwnersHierarchySubset.length)
69
- throw new Error("`dataOwnersHierarchySubset` can't be empty");
70
- const delegationsWithOwner = Object.entries(delegations).flatMap(([delegateId, delegations]) => dataOwnersHierarchySubset.some((dataOwnerId) => dataOwnerId === delegateId)
71
- ? this.populateDelegatedTo(delegateId, delegations)
72
- : this.populateDelegatedTo(delegateId, delegations.filter((d) => dataOwnersHierarchySubset.some((dataOwnerId) => d.owner === dataOwnerId))));
73
- const self = this;
74
- function generator() {
75
- return __asyncGenerator(this, arguments, function* generator_2() {
76
- for (const delegation of delegationsWithOwner) {
77
- const decrypted = yield __await(self.tryDecryptDelegation(delegation, (k) => validateDecrypted(k)));
78
- if (decrypted)
79
- yield yield __await({
80
- decrypted,
81
- dataOwnersWithAccess: delegation.owner ? [delegation.owner, delegation.delegatedTo] : [delegation.delegatedTo],
82
- });
83
- }
84
- });
85
- }
86
- return generator();
87
- }
88
- populateDelegatedTo(delegateId, delegations) {
89
- return delegations.map((d) => (d.delegatedTo === delegateId ? d : Object.assign(Object.assign({}, d), { delegatedTo: delegateId })));
90
- }
91
- tryDecryptDelegation(delegation, validateDecrypted) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const exchangeKeys = yield this.exchangeKeysManager.getDecryptionExchangeKeysFor(delegation.owner, delegation.delegatedTo);
94
- for (const key of exchangeKeys) {
95
- try {
96
- // Format of encrypted key for any delegation should be entityId:key, but with the merging of entities the entityId might not match the
97
- // current id. As a checksum we are only verifying that the decrypted bytes can be represented as a string with exactly one ':'.
98
- // Additionally, we also have a validator that is specific for each type of delegation content (encryption key, secret id, ...)
99
- const decrypted = (0, ModelHelper_1.ua2string)(yield this.primitives.AES.decrypt(key, (0, utils_1.hex2ua)(delegation.key)));
100
- const decryptedSplit = decrypted.split(':');
101
- if (decryptedSplit.length === 2) {
102
- if (yield validateDecrypted(decryptedSplit[1]))
103
- return decryptedSplit[1];
104
- }
105
- else {
106
- console.warn("Error in the decrypted delegation: content should contain exactly 1 ':', the delegation is ignored.");
107
- }
108
- }
109
- catch (e) {
110
- // Do nothing: the delegation uses another exchange key owner->delegator
111
- }
112
- }
113
- });
114
- }
115
- validateEncryptionKey(key) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- return !!(yield this.tryImportKey(key));
118
- });
119
- }
120
- validateSecretId(key) {
121
- return !!key;
122
- }
123
- validateOwningEntityId(key) {
124
- return !!key;
125
- }
126
- tryImportKey(key) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- if (!/^[0-9A-Fa-f\-]+$/g.test(key))
129
- return undefined;
130
- try {
131
- return yield this.primitives.AES.importKey('raw', (0, utils_1.hex2ua)(key.replace(/-/g, '')));
132
- }
133
- catch (e) {
134
- console.warn(`Could not import key ${key} as an encryption key.`, e);
135
- return undefined;
136
- }
137
- });
138
- }
139
- }
140
- exports.LegacyDelegationSecurityMetadataDecryptor = LegacyDelegationSecurityMetadataDecryptor;
141
- //# sourceMappingURL=LegacyDelegationSecurityMetadataDecryptor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LegacyDelegationSecurityMetadataDecryptor.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/LegacyDelegationSecurityMetadataDecryptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,iEAA2D;AAC3D,oCAAiC;AAGjC,2EAAuE;AACvE,IAAO,WAAW,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAGrD,MAAa,yCAAyC;IACpD,YAA6B,mBAAwC,EAAmB,UAA4B;QAAvF,wBAAmB,GAAnB,mBAAmB,CAAqB;QAAmB,eAAU,GAAV,UAAU,CAAkB;IAAG,CAAC;IAExH,uBAAuB,CACrB,WAAoC,EACpC,yBAAmC;QAEnC,SAAgB,SAAS,CACvB,IAA+C;;;gBAE/C,MAAM,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,CAAC,yBAAyB,EAAE,MAAA,WAAW,CAAC,MAAM,CAAC,cAAc,mCAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAC/H,IAAI,CAAC,qBAAqB,CAAC,CAAC,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CAAC;4BAAE,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;qBACzE;yBAAM;wBACL,OAAO,CAAC,IAAI,CAAC,qGAAqG,CAAC,CAAA;qBACpH;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,wEAAwE;iBACzE;aACF;QACH,CAAC;KAAA;IAEa,qBAAqB,CAAC,GAAW;;YAC7C,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;QACzC,CAAC;KAAA;IAEO,gBAAgB,CAAC,GAAW;QAClC,OAAO,CAAC,CAAC,GAAG,CAAA;IACd,CAAC;IAEO,sBAAsB,CAAC,GAAW;QACxC,OAAO,CAAC,CAAC,GAAG,CAAA;IACd,CAAC;IAEa,YAAY,CAAC,GAAW;;YACpC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,OAAO,SAAS,CAAA;YACpD,IAAI;gBACF,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,IAAA,cAAM,EAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;aACjF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,EAAE,CAAC,CAAC,CAAA;gBACpE,OAAO,SAAS,CAAA;aACjB;QACH,CAAC;KAAA;CACF;AA5HD,8FA4HC","sourcesContent":["import { SecurityMetadataDecryptor } from './SecurityMetadataDecryptor'\nimport { EncryptedEntityWithType } from '../utils/EntityWithDelegationTypeName'\nimport { Delegation } from '../../icc-api/model/Delegation'\nimport { ua2string } from '../../icc-api/model/ModelHelper'\nimport { hex2ua } from '../utils'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { ExchangeKeysManager } from './ExchangeKeysManager'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\nimport { EncryptedEntity, EncryptedEntityStub } from '../../icc-api/model/models'\n\nexport class LegacyDelegationSecurityMetadataDecryptor implements SecurityMetadataDecryptor {\n constructor(private readonly exchangeKeysManager: ExchangeKeysManager, private readonly primitives: CryptoPrimitives) {}\n\n decryptEncryptionKeysOf(\n typedEntity: EncryptedEntityWithType,\n dataOwnersHierarchySubset: string[]\n ): AsyncGenerator<{ decrypted: string; dataOwnersWithAccess: string[] }, void, never> {\n async function* generator(\n self: LegacyDelegationSecurityMetadataDecryptor\n ): AsyncGenerator<{ decrypted: string; dataOwnersWithAccess: string[] }, void, never> {\n const decryptedGenerator = self.extractFromDelegations(dataOwnersHierarchySubset, typedEntity.entity.encryptionKeys ?? {}, (d) =>\n self.validateEncryptionKey(d)\n )\n let next = await decryptedGenerator.next()\n while (!next.done) {\n yield { decrypted: next.value.decrypted.replace(/-/g, ''), dataOwnersWithAccess: next.value.dataOwnersWithAccess }\n next = await decryptedGenerator.next()\n }\n }\n return generator(this)\n }\n\n decryptOwningEntityIdsOf(\n typedEntity: EncryptedEntityWithType,\n dataOwnersHierarchySubset: string[]\n ): AsyncGenerator<{ decrypted: string; dataOwnersWithAccess: string[] }, void, never> {\n return this.extractFromDelegations(dataOwnersHierarchySubset, typedEntity.entity.cryptedForeignKeys ?? {}, (d) =>\n Promise.resolve(this.validateOwningEntityId(d))\n )\n }\n\n decryptSecretIdsOf(\n typedEntity: EncryptedEntityWithType,\n dataOwnersHierarchySubset: string[]\n ): AsyncGenerator<{ decrypted: string; dataOwnersWithAccess: string[] }, void, never> {\n return this.extractFromDelegations(dataOwnersHierarchySubset, typedEntity.entity.delegations ?? {}, (d) =>\n Promise.resolve(this.validateSecretId(d))\n )\n }\n\n getEntityAccessLevel(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): Promise<AccessLevel | undefined> {\n const delegatesSet = new Set(Object.keys(typedEntity.entity.delegations ?? {}))\n return dataOwnersHierarchySubset.some((dataOwner) => delegatesSet.has(dataOwner))\n ? Promise.resolve(AccessLevel.WRITE)\n : Promise.resolve(undefined)\n }\n\n hasAnyEncryptionKeys(entity: EncryptedEntity | EncryptedEntityStub): boolean {\n return Object.values(entity.encryptionKeys ?? {}).some((delegations) => delegations.length > 0)\n }\n\n private extractFromDelegations(\n dataOwnersHierarchySubset: string[],\n delegations: { [delegateId: string]: Delegation[] },\n validateDecrypted: (result: string) => Promise<boolean>\n ): AsyncGenerator<{ decrypted: string; dataOwnersWithAccess: string[] }, void, never> {\n if (!dataOwnersHierarchySubset.length) throw new Error(\"`dataOwnersHierarchySubset` can't be empty\")\n const delegationsWithOwner = Object.entries(delegations).flatMap(([delegateId, delegations]) =>\n dataOwnersHierarchySubset.some((dataOwnerId) => dataOwnerId === delegateId)\n ? this.populateDelegatedTo(delegateId, delegations)\n : this.populateDelegatedTo(\n delegateId,\n delegations.filter((d) => dataOwnersHierarchySubset.some((dataOwnerId) => d.owner === dataOwnerId))\n )\n )\n const self = this\n async function* generator() {\n for (const delegation of delegationsWithOwner) {\n const decrypted = await self.tryDecryptDelegation(delegation, (k) => validateDecrypted(k))\n if (decrypted)\n yield {\n decrypted,\n dataOwnersWithAccess: delegation.owner ? [delegation.owner, delegation.delegatedTo!] : [delegation.delegatedTo!],\n }\n }\n }\n return generator()\n }\n\n private populateDelegatedTo(delegateId: string, delegations: Delegation[]): Delegation[] {\n return delegations.map((d) => (d.delegatedTo === delegateId ? d : { ...d, delegatedTo: delegateId }))\n }\n\n private async tryDecryptDelegation(delegation: Delegation, validateDecrypted: (result: string) => Promise<boolean>): Promise<string | undefined> {\n const exchangeKeys = await this.exchangeKeysManager.getDecryptionExchangeKeysFor(delegation.owner!, delegation.delegatedTo!)\n for (const key of exchangeKeys) {\n try {\n // Format of encrypted key for any delegation should be entityId:key, but with the merging of entities the entityId might not match the\n // current id. As a checksum we are only verifying that the decrypted bytes can be represented as a string with exactly one ':'.\n // Additionally, we also have a validator that is specific for each type of delegation content (encryption key, secret id, ...)\n const decrypted = ua2string(await this.primitives.AES.decrypt(key, hex2ua(delegation.key!)))\n const decryptedSplit = decrypted.split(':')\n if (decryptedSplit.length === 2) {\n if (await validateDecrypted(decryptedSplit[1])) return decryptedSplit[1]\n } else {\n console.warn(\"Error in the decrypted delegation: content should contain exactly 1 ':', the delegation is ignored.\")\n }\n } catch (e) {\n // Do nothing: the delegation uses another exchange key owner->delegator\n }\n }\n }\n\n private async validateEncryptionKey(key: string): Promise<boolean> {\n return !!(await this.tryImportKey(key))\n }\n\n private validateSecretId(key: string): boolean {\n return !!key\n }\n\n private validateOwningEntityId(key: string): boolean {\n return !!key\n }\n\n private async tryImportKey(key: string): Promise<CryptoKey | undefined> {\n if (!/^[0-9A-Fa-f\\-]+$/g.test(key)) return undefined\n try {\n return await this.primitives.AES.importKey('raw', hex2ua(key.replace(/-/g, '')))\n } catch (e) {\n console.warn(`Could not import key ${key} as an encryption key.`, e)\n return undefined\n }\n }\n}\n"]}
@@ -1,46 +0,0 @@
1
- import { SecurityMetadataDecryptor } from './SecurityMetadataDecryptor';
2
- import { SecureDelegation } from '../../icc-api/model/SecureDelegation';
3
- import { ExchangeDataManager } from './ExchangeDataManager';
4
- import { EncryptedEntityWithType } from '../utils/EntityWithDelegationTypeName';
5
- import { SecureDelegationsEncryption } from './SecureDelegationsEncryption';
6
- import AccessLevel = SecureDelegation.AccessLevelEnum;
7
- import { EncryptedEntity, EncryptedEntityStub } from '../../icc-api/model/models';
8
- import { IccDataOwnerXApi } from '../icc-data-owner-x-api';
9
- import { ExchangeDataMapManager } from './ExchangeDataMapManager';
10
- import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
11
- export type DelegationMembersDetails = {
12
- delegator: string | undefined;
13
- delegate: string | undefined;
14
- fullyExplicit: boolean;
15
- accessControlSecret: string | undefined;
16
- accessLevel: AccessLevelEnum;
17
- };
18
- export declare class SecureDelegationsSecurityMetadataDecryptor implements SecurityMetadataDecryptor {
19
- private readonly exchangeData;
20
- private readonly exchangeDataMap;
21
- private readonly secureDelegationsEncryption;
22
- private readonly dataOwnerApi;
23
- constructor(exchangeData: ExchangeDataManager, exchangeDataMap: ExchangeDataMapManager, secureDelegationsEncryption: SecureDelegationsEncryption, dataOwnerApi: IccDataOwnerXApi);
24
- decryptEncryptionKeysOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
25
- decrypted: string;
26
- dataOwnersWithAccess: string[];
27
- }, void, never>;
28
- decryptOwningEntityIdsOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
29
- decrypted: string;
30
- dataOwnersWithAccess: string[];
31
- }, void, never>;
32
- decryptSecretIdsOf(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): AsyncGenerator<{
33
- decrypted: string;
34
- dataOwnersWithAccess: string[];
35
- }, void, never>;
36
- /**
37
- * Get information for members of secure delegations in the entity. Also provides information for delegations with anonymous delegate and/or
38
- * delegator if one of the delegation members is the current data owner (or a parent) AND has still access to the exchange data used in the .
39
- */
40
- getDelegationMemberDetails(typedEntity: EncryptedEntityWithType): Promise<{
41
- [delegationKey: string]: DelegationMembersDetails;
42
- }>;
43
- hasAnyEncryptionKeys(entity: EncryptedEntity | EncryptedEntityStub): boolean;
44
- getEntityAccessLevel(typedEntity: EncryptedEntityWithType, dataOwnersHierarchySubset: string[]): Promise<AccessLevel | undefined>;
45
- private decryptSecureDelegations;
46
- }