@icure/api 8.4.15 → 8.5.1
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/icc-api/api/IccApplicationsettingsApi.d.ts +13 -1
- package/icc-api/api/IccApplicationsettingsApi.js +70 -24
- package/icc-api/api/IccApplicationsettingsApi.js.map +1 -1
- package/icc-api/model/ApplicationSettings.d.ts +32 -0
- package/icc-api/model/ApplicationSettings.js.map +1 -1
- package/icc-x-api/crypto/ExchangeKeysManager.js +2 -2
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
- package/icc-x-api/icc-application-settings-x-api.d.ts +76 -0
- package/icc-x-api/icc-application-settings-x-api.js +160 -0
- package/icc-x-api/icc-application-settings-x-api.js.map +1 -0
- package/icc-x-api/index.d.ts +3 -2
- package/icc-x-api/index.js +2 -2
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/EntityWithDelegationTypeName.d.ts +1 -0
- package/icc-x-api/utils/EntityWithDelegationTypeName.js +2 -0
- package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/icc-application-settings-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-application-settings-x-api.js +91 -0
- package/test/icc-x-api/icc-application-settings-x-api.js.map +1 -0
- package/test/utils/roles.js +8 -0
- package/test/utils/roles.js.map +1 -1
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
import { XHR } from './XHR';
|
|
13
13
|
import { ApplicationSettings } from '../model/ApplicationSettings';
|
|
14
14
|
import { AuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider';
|
|
15
|
+
import { BulkShareOrUpdateMetadataParams } from '../model/requests/BulkShareOrUpdateMetadataParams';
|
|
16
|
+
import { EntityBulkShareResult } from '../model/requests/EntityBulkShareResult';
|
|
17
|
+
import { MinimalEntityBulkShareResult } from '../model/requests/MinimalEntityBulkShareResult';
|
|
15
18
|
export declare class IccApplicationsettingsApi {
|
|
16
19
|
host: string;
|
|
17
|
-
|
|
20
|
+
_headers: Array<XHR.Header>;
|
|
18
21
|
authenticationProvider: AuthenticationProvider;
|
|
19
22
|
fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
23
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
20
24
|
constructor(host: string, headers: any, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
21
25
|
setHeaders(h: Array<XHR.Header>): void;
|
|
22
26
|
handleError(e: XHR.XHRError): never;
|
|
@@ -37,4 +41,12 @@ export declare class IccApplicationsettingsApi {
|
|
|
37
41
|
* @param body
|
|
38
42
|
*/
|
|
39
43
|
updateApplicationSettings(body?: ApplicationSettings): Promise<ApplicationSettings>;
|
|
44
|
+
/**
|
|
45
|
+
* @internal this method is for internal use only and may be changed without notice
|
|
46
|
+
*/
|
|
47
|
+
bulkShareApplicationSettings(request: BulkShareOrUpdateMetadataParams): Promise<EntityBulkShareResult<ApplicationSettings>[]>;
|
|
48
|
+
/**
|
|
49
|
+
* @internal this method is for internal use only and may be changed without notice
|
|
50
|
+
*/
|
|
51
|
+
bulkShareApplicationSettingsMinimal(request: BulkShareOrUpdateMetadataParams): Promise<MinimalEntityBulkShareResult[]>;
|
|
40
52
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.IccApplicationsettingsApi = void 0;
|
|
4
13
|
/**
|
|
@@ -16,15 +25,20 @@ const XHR_1 = require("./XHR");
|
|
|
16
25
|
const ApplicationSettings_1 = require("../model/ApplicationSettings");
|
|
17
26
|
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
|
|
18
27
|
const IccRestApiPath_1 = require("./IccRestApiPath");
|
|
28
|
+
const EntityBulkShareResult_1 = require("../model/requests/EntityBulkShareResult");
|
|
29
|
+
const MinimalEntityBulkShareResult_1 = require("../model/requests/MinimalEntityBulkShareResult");
|
|
19
30
|
class IccApplicationsettingsApi {
|
|
31
|
+
get headers() {
|
|
32
|
+
return Promise.resolve(this._headers);
|
|
33
|
+
}
|
|
20
34
|
constructor(host, headers, authenticationProvider, fetchImpl) {
|
|
21
35
|
this.host = (0, IccRestApiPath_1.iccRestApiPath)(host);
|
|
22
|
-
this.
|
|
36
|
+
this._headers = Object.keys(headers).map((k) => new XHR_1.XHR.Header(k, headers[k]));
|
|
23
37
|
this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new AuthenticationProvider_1.NoAuthenticationProvider();
|
|
24
38
|
this.fetchImpl = fetchImpl;
|
|
25
39
|
}
|
|
26
40
|
setHeaders(h) {
|
|
27
|
-
this.
|
|
41
|
+
this._headers = h;
|
|
28
42
|
}
|
|
29
43
|
handleError(e) {
|
|
30
44
|
throw e;
|
|
@@ -35,26 +49,30 @@ class IccApplicationsettingsApi {
|
|
|
35
49
|
* @param body
|
|
36
50
|
*/
|
|
37
51
|
createApplicationSettings(body) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let _body = null;
|
|
54
|
+
_body = body;
|
|
55
|
+
const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime();
|
|
56
|
+
let headers = yield this.headers;
|
|
57
|
+
headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
58
|
+
return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
|
|
59
|
+
.then((doc) => new ApplicationSettings_1.ApplicationSettings(doc.body))
|
|
60
|
+
.catch((err) => this.handleError(err));
|
|
61
|
+
});
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
48
64
|
*
|
|
49
65
|
* @summary Gets all application settings
|
|
50
66
|
*/
|
|
51
67
|
getApplicationSettings() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
let _body = null;
|
|
70
|
+
const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime();
|
|
71
|
+
let headers = yield this.headers;
|
|
72
|
+
return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
|
|
73
|
+
.then((doc) => doc.body.map((it) => new ApplicationSettings_1.ApplicationSettings(it)))
|
|
74
|
+
.catch((err) => this.handleError(err));
|
|
75
|
+
});
|
|
58
76
|
}
|
|
59
77
|
/**
|
|
60
78
|
*
|
|
@@ -62,14 +80,42 @@ class IccApplicationsettingsApi {
|
|
|
62
80
|
* @param body
|
|
63
81
|
*/
|
|
64
82
|
updateApplicationSettings(body) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
let _body = null;
|
|
85
|
+
_body = body;
|
|
86
|
+
const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime();
|
|
87
|
+
let headers = yield this.headers;
|
|
88
|
+
headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
89
|
+
return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
|
|
90
|
+
.then((doc) => new ApplicationSettings_1.ApplicationSettings(doc.body))
|
|
91
|
+
.catch((err) => this.handleError(err));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal this method is for internal use only and may be changed without notice
|
|
96
|
+
*/
|
|
97
|
+
bulkShareApplicationSettings(request) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const _url = this.host + '/appsettings/bulkSharedMetadataUpdate' + '?ts=' + new Date().getTime();
|
|
100
|
+
let headers = yield this.headers;
|
|
101
|
+
headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
102
|
+
return XHR_1.XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
|
|
103
|
+
.then((doc) => doc.body.map((x) => new EntityBulkShareResult_1.EntityBulkShareResult(x, ApplicationSettings_1.ApplicationSettings)))
|
|
104
|
+
.catch((err) => this.handleError(err));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @internal this method is for internal use only and may be changed without notice
|
|
109
|
+
*/
|
|
110
|
+
bulkShareApplicationSettingsMinimal(request) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const _url = this.host + '/appsettings/bulkSharedMetadataUpdateMinimal' + '?ts=' + new Date().getTime();
|
|
113
|
+
let headers = yield this.headers;
|
|
114
|
+
headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
|
|
115
|
+
return XHR_1.XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
|
|
116
|
+
.then((doc) => doc.body.map((x) => new MinimalEntityBulkShareResult_1.MinimalEntityBulkShareResult(x)))
|
|
117
|
+
.catch((err) => this.handleError(err));
|
|
118
|
+
});
|
|
73
119
|
}
|
|
74
120
|
}
|
|
75
121
|
exports.IccApplicationsettingsApi = IccApplicationsettingsApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IccApplicationsettingsApi.js","sourceRoot":"","sources":["../../../icc-api/api/IccApplicationsettingsApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IccApplicationsettingsApi.js","sourceRoot":"","sources":["../../../icc-api/api/IccApplicationsettingsApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,+BAA2B;AAC3B,sEAAkE;AAClE,wFAA8G;AAC9G,qDAAiD;AAEjD,mFAA+E;AAE/E,iGAA6F;AAE7F,MAAa,yBAAyB;IAMpC,IAAI,OAAO;QACT,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAED,YACE,IAAY,EACZ,OAAY,EACZ,sBAA+C,EAC/C,SAAyE;QAEzE,IAAI,CAAC,IAAI,GAAG,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,SAAG,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9E,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,iDAAwB,EAAE,CAAA;QAChH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,UAAU,CAAC,CAAoB;QAC7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AC,IAAI,SAAG,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAA;YACvH,OAAO,SAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;iBAC3H,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAE,GAAG,CAAC,IAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,2DAA4B,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxF,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,CAAC;KAAA;CACF;AArGD,8DAqGC","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 { ApplicationSettings } from '../model/ApplicationSettings'\nimport { AuthenticationProvider, NoAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { iccRestApiPath } from './IccRestApiPath'\nimport { BulkShareOrUpdateMetadataParams } from '../model/requests/BulkShareOrUpdateMetadataParams'\nimport { EntityBulkShareResult } from '../model/requests/EntityBulkShareResult'\nimport { Classification } from '../model/Classification'\nimport { MinimalEntityBulkShareResult } from '../model/requests/MinimalEntityBulkShareResult'\n\nexport class IccApplicationsettingsApi {\n host: string\n _headers: Array<XHR.Header>\n authenticationProvider: AuthenticationProvider\n fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n get headers(): Promise<Array<XHR.Header>> {\n return Promise.resolve(this._headers)\n }\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 Create new application settings\n * @param body\n */\n async createApplicationSettings(body?: ApplicationSettings): Promise<ApplicationSettings> {\n let _body = null\n _body = body\n\n const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime()\n let headers = await 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 ApplicationSettings(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Gets all application settings\n */\n async getApplicationSettings(): Promise<Array<ApplicationSettings>> {\n let _body = null\n\n const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime()\n let headers = await this.headers\n return XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((it) => new ApplicationSettings(it)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n *\n * @summary Update application settings\n * @param body\n */\n async updateApplicationSettings(body?: ApplicationSettings): Promise<ApplicationSettings> {\n let _body = null\n _body = body\n\n const _url = this.host + `/appsettings` + '?ts=' + new Date().getTime()\n let headers = await 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 ApplicationSettings(doc.body as JSON))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n */\n async bulkShareApplicationSettings(request: BulkShareOrUpdateMetadataParams): Promise<EntityBulkShareResult<ApplicationSettings>[]> {\n const _url = this.host + '/appsettings/bulkSharedMetadataUpdate' + '?ts=' + new Date().getTime()\n let headers = await 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, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((x) => new EntityBulkShareResult<ApplicationSettings>(x, ApplicationSettings)))\n .catch((err) => this.handleError(err))\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n */\n async bulkShareApplicationSettingsMinimal(request: BulkShareOrUpdateMetadataParams): Promise<MinimalEntityBulkShareResult[]> {\n const _url = this.host + '/appsettings/bulkSharedMetadataUpdateMinimal' + '?ts=' + new Date().getTime()\n let headers = await 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, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => (doc.body as Array<JSON>).map((x) => new MinimalEntityBulkShareResult(x)))\n .catch((err) => this.handleError(err))\n }\n}\n"]}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
import { CodeStub } from './CodeStub';
|
|
13
|
+
import { Delegation } from './Delegation';
|
|
14
|
+
import { SecurityMetadata } from './SecurityMetadata';
|
|
13
15
|
export declare class ApplicationSettings {
|
|
14
16
|
constructor(json: JSON | any);
|
|
15
17
|
id?: string;
|
|
@@ -53,4 +55,34 @@ export declare class ApplicationSettings {
|
|
|
53
55
|
settings?: {
|
|
54
56
|
[key: string]: string;
|
|
55
57
|
};
|
|
58
|
+
encryptedSettings?: {
|
|
59
|
+
[key: string]: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find all contacts for a specific patient. These keys are in clear. You can have several to partition the medical document space.
|
|
63
|
+
*/
|
|
64
|
+
secretForeignKeys?: Array<string>;
|
|
65
|
+
/**
|
|
66
|
+
* The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find the patient for a specific contact. These keys are the encrypted id (using the hcParty key for the delegate) that can be found in clear inside the patient. ids encrypted using the hcParty keys.
|
|
67
|
+
*/
|
|
68
|
+
cryptedForeignKeys?: {
|
|
69
|
+
[key: string]: Array<Delegation>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* When a document is created, the responsible generates a cryptographically random master key (never to be used for something else than referencing from other entities). He/she encrypts it using his own AES exchange key and stores it as a delegation. The responsible is thus always in the delegations as well
|
|
73
|
+
*/
|
|
74
|
+
delegations?: {
|
|
75
|
+
[key: string]: Array<Delegation>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* When a document needs to be encrypted, the responsible generates a cryptographically random master key (different from the delegation key, never to appear in clear anywhere in the db. He/she encrypts it using his own AES exchange key and stores it as a delegation
|
|
79
|
+
*/
|
|
80
|
+
encryptionKeys?: {
|
|
81
|
+
[key: string]: Array<Delegation>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The base64 encoded data of this object, formatted as JSON and encrypted in AES using the random master key from encryptionKeys.
|
|
85
|
+
*/
|
|
86
|
+
encryptedSelf?: string;
|
|
87
|
+
securityMetadata?: SecurityMetadata;
|
|
56
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationSettings.js","sourceRoot":"","sources":["../../../icc-api/model/ApplicationSettings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ApplicationSettings.js","sourceRoot":"","sources":["../../../icc-api/model/ApplicationSettings.ts"],"names":[],"mappings":";;;AAeA,MAAa,mBAAmB;IAC9B,YAAY,IAAgB;QAC1B,MAAM,CAAC,MAAM,CAAC,IAA2B,EAAE,IAAI,CAAC,CAAA;IAClD,CAAC;CA+DF;AAlED,kDAkEC","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 { CodeStub } from './CodeStub'\nimport { Delegation } from './Delegation'\nimport { SecurityMetadata } from './SecurityMetadata'\n\nexport class ApplicationSettings {\n constructor(json: JSON | any) {\n Object.assign(this as ApplicationSettings, json)\n }\n\n id?: string\n rev?: string\n /**\n * The timestamp (unix epoch in ms) of creation of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n created?: number\n /**\n * The date (unix epoch in ms) of the latest modification of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n modified?: number\n /**\n * The id of the User that has created this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n author?: string\n /**\n * The id of the HealthcareParty that is responsible for this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n responsible?: string\n /**\n * The id of the medical location where this entity was created.\n */\n medicalLocationId?: string\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * A code is an item from a codification system that qualifies the content of this entity. SNOMED-CT, ICPC-2 or ICD-10 codifications systems can be used for codes\n */\n codes?: Array<CodeStub>\n /**\n * Soft delete (unix epoch in ms) timestamp of the object.\n */\n endOfLife?: number\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n settings?: { [key: string]: string }\n encryptedSettings?: { [key: string]: string }\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find all contacts for a specific patient. These keys are in clear. You can have several to partition the medical document space.\n */\n secretForeignKeys?: Array<string>\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find the patient for a specific contact. These keys are the encrypted id (using the hcParty key for the delegate) that can be found in clear inside the patient. ids encrypted using the hcParty keys.\n */\n cryptedForeignKeys?: { [key: string]: Array<Delegation> }\n /**\n * When a document is created, the responsible generates a cryptographically random master key (never to be used for something else than referencing from other entities). He/she encrypts it using his own AES exchange key and stores it as a delegation. The responsible is thus always in the delegations as well\n */\n delegations?: { [key: string]: Array<Delegation> }\n /**\n * When a document needs to be encrypted, the responsible generates a cryptographically random master key (different from the delegation key, never to appear in clear anywhere in the db. He/she encrypts it using his own AES exchange key and stores it as a delegation\n */\n encryptionKeys?: { [key: string]: Array<Delegation> }\n /**\n * The base64 encoded data of this object, formatted as JSON and encrypted in AES using the random master key from encryptionKeys.\n */\n encryptedSelf?: string\n securityMetadata?: SecurityMetadata\n}\n"]}
|
|
@@ -26,7 +26,7 @@ class ExchangeKeysManager {
|
|
|
26
26
|
this.keyManager = keyManager;
|
|
27
27
|
this.baseExchangeKeysManager = baseExchangeKeysManager;
|
|
28
28
|
this.dataOwnerApi = dataOwnerApi;
|
|
29
|
-
this.cache =
|
|
29
|
+
this.cache = this.doGetCache(); // Intentionally not awaited to make login feel faster
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current
|
|
@@ -66,7 +66,7 @@ class ExchangeKeysManager {
|
|
|
66
66
|
* Reloads all exchange keys for the cache.
|
|
67
67
|
*/
|
|
68
68
|
reloadCache() {
|
|
69
|
-
this.cache = this.doGetCache(); // Intentionally not awaited to make
|
|
69
|
+
this.cache = this.doGetCache(); // Intentionally not awaited to make reload feel faster
|
|
70
70
|
}
|
|
71
71
|
doGetCache() {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExchangeKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAG9B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,uBAAuB,CAAA;IACrC,CAAC;IAED,YACmB,UAAqC,EACrC,uBAAgD,EAChD,YAA8B;QAF9B,eAAU,GAAV,UAAU,CAA2B;QACrC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,iBAAY,GAAZ,YAAY,CAAkB;
|
|
1
|
+
{"version":3,"file":"ExchangeKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAG9B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,uBAAuB,CAAA;IACrC,CAAC;IAED,YACmB,UAAqC,EACrC,uBAAgD,EAChD,YAA8B;QAF9B,eAAU,GAAV,UAAU,CAA2B;QACrC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,iBAAY,GAAZ,YAAY,CAAkB;QAE/C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA,CAAC,sDAAsD;IACvF,CAAC;IAED;;;;;;;OAOG;IACG,4BAA4B,CAAC,WAAmB,EAAE,UAAkB;;;YACxE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAA;YAC9B,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,WAAW,CAAC,0CAAG,UAAU,CAAC,CAAA;YAC9C,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;gBACvB,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;oBACzB,OAAO,MAA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AAC,gBAAgB,CAAC,CAAA;oBACrE,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,aAAa,CAAA;QACtB,CAAC;KAAA;CACF;AAlGD,kDAkGC","sourcesContent":["import { UserEncryptionKeysManager } from './UserEncryptionKeysManager'\nimport { BaseExchangeKeysManager } from './BaseExchangeKeysManager'\nimport { IccDataOwnerXApi } from '../icc-data-owner-x-api'\nimport { CryptoPrimitives } from './CryptoPrimitives'\nimport { CryptoStrategies } from './CryptoStrategies'\nimport { IcureStorageFacade } from '../storage/IcureStorageFacade'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\n\ntype CacheValue =\n | {\n encrypted: { [fp: string]: string }[]\n }\n | {\n decrypted: Promise<CryptoKey[]>\n }\n\n/**\n * @internal This class is meant only for internal use and may be changed without notice.\n * More powerful version of {@link BaseExchangeKeysManager} with a simplified interface. Has the following functionalities:\n * - Caches results\n * - Automatically creates new exchange keys if none is available\n * - Automatically choose the public keys to use during the creation of new exchange keys\n * - Automatically retrieves the private keys to use during decryption.\n */\nexport class ExchangeKeysManager {\n private cache: Promise<{ [delegator: string]: { [delegate: string]: CacheValue } }>\n\n get base(): BaseExchangeKeysManager {\n return this.baseExchangeKeysManager\n }\n\n constructor(\n private readonly keyManager: UserEncryptionKeysManager,\n private readonly baseExchangeKeysManager: BaseExchangeKeysManager,\n private readonly dataOwnerApi: IccDataOwnerXApi\n ) {\n this.cache = this.doGetCache() // Intentionally not awaited to make login feel faster\n }\n\n /**\n * Get all keys currently available for a delegator-delegate pair. At least one of the two data owners must be part of the hierarchy for the current\n * data owner.\n * @param delegatorId id of a delegator\n * @param delegateId id of a delegate\n * @throws if neither the delegator nor the delegate is part of the hierarchy of the current data owner.\n * @return all available exchange keys from the delegator-delegate pair.\n */\n async getDecryptionExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]> {\n const cache = await this.cache\n const entry = cache[delegatorId]?.[delegateId]\n if (entry != undefined) {\n if ('decrypted' in entry) {\n return await entry.decrypted\n } else {\n const decryptedPromise = this.decryptChunk(entry.encrypted)\n cache[delegatorId][delegateId] = { decrypted: decryptedPromise }\n return await decryptedPromise\n }\n } else {\n return []\n }\n }\n\n private async decryptChunk(encryptedKeys: { [fp: string]: string }[]): Promise<CryptoKey[]> {\n const decryptionKeys = this.keyManager.getDecryptionKeys()\n return (await this.base.tryDecryptExchangeKeys(encryptedKeys, decryptionKeys)).successfulDecryptions\n }\n\n /**\n * Reloads all exchange keys for the cache.\n */\n reloadCache(): void {\n this.cache = this.doGetCache() // Intentionally not awaited to make reload feel faster\n }\n\n private async doGetCache() {\n const hierarchy = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds()\n const encryptedKeysDataByHierarchyMember = Object.fromEntries(\n await Promise.all(\n hierarchy.map((doId) =>\n this.base.getAllExchangeKeysWith(doId, null).then(\n (\n res\n ): [\n string,\n {\n keysToOwner: { [p: string]: { [p: string]: { [p: string]: string } } }\n keysFromOwner: { [p: string]: { [p: string]: { [p: string]: string } } }\n }\n ] => [doId, res]\n )\n )\n )\n )\n const encryptedKeys: { [delegator: string]: { [delegate: string]: { encrypted: { [pubFp: string]: string }[] } } } = {}\n for (const [dataOwner, info] of Object.entries(encryptedKeysDataByHierarchyMember)) {\n for (const [delegator, encryptedByDelegatorFp] of Object.entries(info.keysToOwner)) {\n if (!encryptedKeys[delegator]) {\n encryptedKeys[delegator] = {}\n }\n if (!encryptedKeys[delegator][dataOwner]) {\n encryptedKeys[delegator][dataOwner] = { encrypted: [] }\n }\n const keysForDelegatorDelegate = encryptedKeys[delegator][dataOwner]\n for (const encryptedEntries of Object.values(encryptedByDelegatorFp)) {\n keysForDelegatorDelegate.encrypted.push(encryptedEntries)\n }\n }\n for (const encryptedByDelegateId of Object.values(info.keysFromOwner)) {\n for (const [delegate, encryptedEntries] of Object.entries(encryptedByDelegateId)) {\n if (!encryptedKeys[dataOwner]) {\n encryptedKeys[dataOwner] = {}\n }\n if (!encryptedKeys[dataOwner][delegate]) {\n encryptedKeys[dataOwner][delegate] = { encrypted: [] }\n }\n encryptedKeys[dataOwner][delegate].encrypted.push(encryptedEntries)\n }\n }\n }\n return encryptedKeys\n }\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { IccApplicationsettingsApi } from '../icc-api';
|
|
13
|
+
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
|
|
14
|
+
import * as models from '../icc-api/model/models';
|
|
15
|
+
import { IccCryptoXApi } from './icc-crypto-x-api';
|
|
16
|
+
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
17
|
+
import { SecretIdUseOption } from './crypto/SecretIdUseOption';
|
|
18
|
+
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
19
|
+
import { ShareResult } from './utils/ShareResult';
|
|
20
|
+
import { ApplicationSettings, SecureDelegation, User } from '../icc-api/model/models';
|
|
21
|
+
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
|
|
22
|
+
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
23
|
+
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
|
|
24
|
+
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
|
|
25
|
+
import { XHR } from '../icc-api/api/XHR';
|
|
26
|
+
export declare class IccApplicationSettingsXApi extends IccApplicationsettingsApi implements EncryptedEntityXApi<models.ApplicationSettings> {
|
|
27
|
+
private readonly autofillAuthor;
|
|
28
|
+
crypto: IccCryptoXApi;
|
|
29
|
+
dataOwnerApi: IccDataOwnerXApi;
|
|
30
|
+
private readonly encryptedFields;
|
|
31
|
+
get headers(): Promise<Array<XHR.Header>>;
|
|
32
|
+
constructor(host: string, headers: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, encryptedKeys?: Array<string>, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
35
|
+
newInstance(user: models.User, c?: any, options?: {
|
|
36
|
+
additionalDelegates?: {
|
|
37
|
+
[dataOwnerId: string]: AccessLevelEnum;
|
|
38
|
+
};
|
|
39
|
+
sfkOption?: SecretIdUseOption;
|
|
40
|
+
ignoreAutoDelegations?: boolean;
|
|
41
|
+
alternateRootDelegation?: string;
|
|
42
|
+
}): Promise<models.ApplicationSettings>;
|
|
43
|
+
hasWriteAccess(applicationSettings: models.ApplicationSettings): Promise<boolean>;
|
|
44
|
+
shareWith(delegateId: string, applicationSettings: models.ApplicationSettings, options?: {
|
|
45
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
46
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
47
|
+
}): Promise<models.ApplicationSettings>;
|
|
48
|
+
shareWithMany(applicationSettings: models.ApplicationSettings, delegates: {
|
|
49
|
+
[delegateId: string]: {
|
|
50
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
51
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
52
|
+
};
|
|
53
|
+
}): Promise<models.ApplicationSettings>;
|
|
54
|
+
tryShareWithMany(applicationSettings: models.ApplicationSettings, delegates: {
|
|
55
|
+
[delegateId: string]: {
|
|
56
|
+
requestedPermissions?: RequestedPermissionEnum;
|
|
57
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
58
|
+
};
|
|
59
|
+
}): Promise<ShareResult<models.ApplicationSettings>>;
|
|
60
|
+
getDataOwnersWithAccessTo(entity: models.ApplicationSettings): Promise<{
|
|
61
|
+
permissionsByDataOwnerId: {
|
|
62
|
+
[p: string]: AccessLevelEnum;
|
|
63
|
+
};
|
|
64
|
+
hasUnknownAnonymousDataOwners: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
getEncryptionKeysOf(entity: models.ApplicationSettings): Promise<string[]>;
|
|
67
|
+
createDelegationDeAnonymizationMetadata(entity: models.ApplicationSettings, delegates: string[]): Promise<void>;
|
|
68
|
+
createApplicationSettings(body?: ApplicationSettings): Promise<never>;
|
|
69
|
+
getApplicationSettings(): Promise<Array<never>>;
|
|
70
|
+
updateApplicationSettings(body?: ApplicationSettings): Promise<never>;
|
|
71
|
+
createApplicationSettingsWithUser(user: User | undefined, body: ApplicationSettings): Promise<ApplicationSettings>;
|
|
72
|
+
getApplicationSettingsWithUser(user: User | undefined): Promise<Array<ApplicationSettings>>;
|
|
73
|
+
updateApplicationSettingsWithUser(user: User | undefined, body: ApplicationSettings): Promise<ApplicationSettings>;
|
|
74
|
+
private tryDecryptOrReturnOriginal;
|
|
75
|
+
private encrypt;
|
|
76
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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.IccApplicationSettingsXApi = 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 icc_api_1 = require("../icc-api");
|
|
25
|
+
const models = require("../icc-api/model/models");
|
|
26
|
+
const utils_1 = require("./utils");
|
|
27
|
+
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
28
|
+
const models_1 = require("../icc-api/model/models");
|
|
29
|
+
var AccessLevelEnum = models_1.SecureDelegation.AccessLevelEnum;
|
|
30
|
+
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
31
|
+
class IccApplicationSettingsXApi extends icc_api_1.IccApplicationsettingsApi {
|
|
32
|
+
get headers() {
|
|
33
|
+
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, utils_1.EntityWithDelegationTypeName.ApplicationSettings));
|
|
34
|
+
}
|
|
35
|
+
constructor(host, headers, crypto, dataOwnerApi, autofillAuthor, encryptedKeys = ['encryptedSettings'], authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
36
|
+
? window.fetch
|
|
37
|
+
: typeof self !== 'undefined'
|
|
38
|
+
? self.fetch
|
|
39
|
+
: fetch) {
|
|
40
|
+
super(host, headers, authenticationProvider, fetchImpl);
|
|
41
|
+
this.autofillAuthor = autofillAuthor;
|
|
42
|
+
this.crypto = crypto;
|
|
43
|
+
this.dataOwnerApi = dataOwnerApi;
|
|
44
|
+
this.encryptedFields = (0, utils_1.parseEncryptedFields)(encryptedKeys, 'ApplicationSettings.');
|
|
45
|
+
}
|
|
46
|
+
newInstance(user_1) {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function* (user, c = {}, options = {}) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
49
|
+
const applicationSettings = Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.ApplicationSettings', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = c === null || c === void 0 ? void 0 : c.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = c === null || c === void 0 ? void 0 : c.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = c === null || c === void 0 ? void 0 : c.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = c === null || c === void 0 ? void 0 : c.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined) });
|
|
50
|
+
const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
|
|
51
|
+
if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
|
|
52
|
+
throw new Error('Can only initialise entities as current data owner.');
|
|
53
|
+
const extraDelegations = Object.assign(Object.assign({}, (options.ignoreAutoDelegations == true
|
|
54
|
+
? {}
|
|
55
|
+
: Object.fromEntries([...((_g = (_f = user.autoDelegations) === null || _f === void 0 ? void 0 : _f.all) !== null && _g !== void 0 ? _g : []), ...((_j = (_h = user.autoDelegations) === null || _h === void 0 ? void 0 : _h.medicalInformation) !== null && _j !== void 0 ? _j : [])].map((d) => [d, AccessLevelEnum.WRITE])))), ((_k = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _k !== void 0 ? _k : {}));
|
|
56
|
+
return new models.ApplicationSettings(yield this.crypto.xapi
|
|
57
|
+
.entityWithInitialisedEncryptedMetadata(applicationSettings, utils_1.EntityWithDelegationTypeName.ApplicationSettings, undefined, [], true, extraDelegations, options.alternateRootDelegation)
|
|
58
|
+
.then((x) => x.updatedEntity));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
hasWriteAccess(applicationSettings) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return this.crypto.xapi.hasWriteAccess({ entity: applicationSettings, type: utils_1.EntityWithDelegationTypeName.ApplicationSettings });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
shareWith(delegateId_1, applicationSettings_1) {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* (delegateId, applicationSettings, options = {}) {
|
|
68
|
+
return this.shareWithMany(applicationSettings, { [delegateId]: options });
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
shareWithMany(applicationSettings, delegates) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
return (yield this.tryShareWithMany(applicationSettings, delegates)).updatedEntityOrThrow;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
tryShareWithMany(applicationSettings, delegates) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
// All entities should have an encryption key.
|
|
79
|
+
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(applicationSettings, utils_1.EntityWithDelegationTypeName.ApplicationSettings);
|
|
80
|
+
const updatedEntity = entityWithEncryptionKey
|
|
81
|
+
? yield this.updateApplicationSettingsWithUser(undefined, entityWithEncryptionKey)
|
|
82
|
+
: applicationSettings;
|
|
83
|
+
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({
|
|
84
|
+
entity: updatedEntity,
|
|
85
|
+
type: utils_1.EntityWithDelegationTypeName.ApplicationSettings,
|
|
86
|
+
}, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
87
|
+
delegateId,
|
|
88
|
+
{
|
|
89
|
+
requestedPermissions: options.requestedPermissions,
|
|
90
|
+
shareEncryptionKeys: options.shareEncryptionKey,
|
|
91
|
+
shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
|
|
92
|
+
shareSecretIds: [],
|
|
93
|
+
},
|
|
94
|
+
])), (x) => this.bulkShareApplicationSettings(x));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getDataOwnersWithAccessTo(entity) {
|
|
98
|
+
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.ApplicationSettings });
|
|
99
|
+
}
|
|
100
|
+
getEncryptionKeysOf(entity) {
|
|
101
|
+
return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.ApplicationSettings }, undefined);
|
|
102
|
+
}
|
|
103
|
+
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
104
|
+
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.ApplicationSettings }, delegates);
|
|
105
|
+
}
|
|
106
|
+
createApplicationSettings(body) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
throw new Error('Use withUser method');
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
getApplicationSettings() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
throw new Error('Use withUser method');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
updateApplicationSettings(body) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
throw new Error('Use withUser method');
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
createApplicationSettingsWithUser(user, body) {
|
|
122
|
+
const _super = Object.create(null, {
|
|
123
|
+
createApplicationSettings: { get: () => super.createApplicationSettings }
|
|
124
|
+
});
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
if (body.securityMetadata == null)
|
|
127
|
+
throw new Error('Application settings does not have initialized encryption metadata; initialize or use non-encrypted api');
|
|
128
|
+
return _super.createApplicationSettings.call(this, (yield this.encrypt([body]))[0]);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
getApplicationSettingsWithUser(user) {
|
|
132
|
+
const _super = Object.create(null, {
|
|
133
|
+
getApplicationSettings: { get: () => super.getApplicationSettings }
|
|
134
|
+
});
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const retrieved = yield _super.getApplicationSettings.call(this);
|
|
137
|
+
return (yield this.tryDecryptOrReturnOriginal(retrieved)).map((x) => x.entity);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
updateApplicationSettingsWithUser(user, body) {
|
|
141
|
+
const _super = Object.create(null, {
|
|
142
|
+
updateApplicationSettings: { get: () => super.updateApplicationSettings }
|
|
143
|
+
});
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (body.securityMetadata == null)
|
|
146
|
+
throw new Error('Application settings does not have initialized encryption metadata; initialize or use non-encrypted api');
|
|
147
|
+
return _super.updateApplicationSettings.call(this, (yield this.encrypt([body]))[0]);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
tryDecryptOrReturnOriginal(applicationSettings) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
return yield this.crypto.xapi.tryDecryptEntities(applicationSettings, utils_1.EntityWithDelegationTypeName.ApplicationSettings, (x) => new models.ApplicationSettings(x));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
encrypt(applicationSettings) {
|
|
156
|
+
return this.crypto.xapi.tryEncryptEntities(applicationSettings, utils_1.EntityWithDelegationTypeName.ApplicationSettings, this.encryptedFields, true, false, (x) => new models.ApplicationSettings(x));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.IccApplicationSettingsXApi = IccApplicationSettingsXApi;
|
|
160
|
+
//# sourceMappingURL=icc-application-settings-x-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icc-application-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AEtD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAC9C,mBAAmB,EACnB,oCAA4B,CAAC,mBAAmB,EAChD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CACzC,CAAA;QACH,CAAC;KAAA;IAEO,OAAO,CAAC,mBAAsD;QACpE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CACxC,mBAAmB,EACnB,oCAA4B,CAAC,mBAAmB,EAChD,IAAI,CAAC,eAAe,EACpB,IAAI,EACJ,KAAK,EACL,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CACzC,CAAA;IACH,CAAC;CACF;AA3MD,gEA2MC","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 { IccApplicationsettingsApi } from '../icc-api'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport * as models from '../icc-api/model/models'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields } from './utils'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { ApplicationSettings, SecureDelegation, User } from '../icc-api/model/models'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\n\nexport class IccApplicationSettingsXApi extends IccApplicationsettingsApi implements EncryptedEntityXApi<models.ApplicationSettings> {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) =>\n this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.ApplicationSettings)\n )\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = ['encryptedSettings'],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'ApplicationSettings.')\n }\n\n async newInstance(\n user: models.User,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.ApplicationSettings> {\n const applicationSettings = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.ApplicationSettings',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n }\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.ApplicationSettings(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n applicationSettings,\n EntityWithDelegationTypeName.ApplicationSettings,\n undefined,\n [],\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n async hasWriteAccess(applicationSettings: models.ApplicationSettings): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: applicationSettings, type: EntityWithDelegationTypeName.ApplicationSettings })\n }\n\n async shareWith(\n delegateId: string,\n applicationSettings: models.ApplicationSettings,\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.ApplicationSettings> {\n return this.shareWithMany(applicationSettings, { [delegateId]: options })\n }\n\n async shareWithMany(\n applicationSettings: models.ApplicationSettings,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.ApplicationSettings> {\n return (await this.tryShareWithMany(applicationSettings, delegates)).updatedEntityOrThrow\n }\n\n async tryShareWithMany(\n applicationSettings: models.ApplicationSettings,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.ApplicationSettings>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n applicationSettings,\n EntityWithDelegationTypeName.ApplicationSettings\n )\n const updatedEntity = entityWithEncryptionKey\n ? await this.updateApplicationSettingsWithUser(undefined, entityWithEncryptionKey)\n : applicationSettings\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.ApplicationSettings,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: [],\n },\n ])\n ),\n (x) => this.bulkShareApplicationSettings(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.ApplicationSettings\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.ApplicationSettings })\n }\n\n getEncryptionKeysOf(entity: models.ApplicationSettings): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.ApplicationSettings }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.ApplicationSettings, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.ApplicationSettings },\n delegates\n )\n }\n\n async createApplicationSettings(body?: ApplicationSettings): Promise<never> {\n throw new Error('Use withUser method')\n }\n async getApplicationSettings(): Promise<Array<never>> {\n throw new Error('Use withUser method')\n }\n async updateApplicationSettings(body?: ApplicationSettings): Promise<never> {\n throw new Error('Use withUser method')\n }\n\n async createApplicationSettingsWithUser(user: User | undefined, body: ApplicationSettings): Promise<ApplicationSettings> {\n if (body.securityMetadata == null)\n throw new Error('Application settings does not have initialized encryption metadata; initialize or use non-encrypted api')\n return super.createApplicationSettings((await this.encrypt([body]))[0])\n }\n\n async getApplicationSettingsWithUser(user: User | undefined): Promise<Array<ApplicationSettings>> {\n const retrieved = await super.getApplicationSettings()\n return (await this.tryDecryptOrReturnOriginal(retrieved)).map((x) => x.entity)\n }\n\n async updateApplicationSettingsWithUser(user: User | undefined, body: ApplicationSettings): Promise<ApplicationSettings> {\n if (body.securityMetadata == null)\n throw new Error('Application settings does not have initialized encryption metadata; initialize or use non-encrypted api')\n return super.updateApplicationSettings((await this.encrypt([body]))[0])\n }\n\n private async tryDecryptOrReturnOriginal(\n applicationSettings: Array<models.ApplicationSettings>\n ): Promise<{ entity: models.ApplicationSettings; decrypted: boolean }[]> {\n return await this.crypto.xapi.tryDecryptEntities(\n applicationSettings,\n EntityWithDelegationTypeName.ApplicationSettings,\n (x) => new models.ApplicationSettings(x)\n )\n }\n\n private encrypt(applicationSettings: Array<models.ApplicationSettings>): Promise<Array<models.ApplicationSettings>> {\n return this.crypto.xapi.tryEncryptEntities(\n applicationSettings,\n EntityWithDelegationTypeName.ApplicationSettings,\n this.encryptedFields,\n true,\n false,\n (x) => new models.ApplicationSettings(x)\n )\n }\n}\n"]}
|