@icure/api 8.0.18 → 8.0.20

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.
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ /*
3
+ * Participants: A, B children hcp of P ; X external hcp, not related to A/B/P.
4
+ *
5
+
6
+ * Situation 2:
7
+ * Entity E with legacy metadata created by A and shared with P.
8
+ * There is also a confidential secret id (known by A but not P).
9
+ * A wants to share with X as read only.
10
+ * Expected outcome:
11
+ * - A root secure delegation for A
12
+ * - A->A includes the confidential secret id known by A
13
+ * - A delegation from A to P
14
+ * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)
15
+ */
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const icc_x_api_1 = require("../../../icc-x-api");
27
+ const crypto_1 = require("crypto");
28
+ const test_utils_1 = require("../../utils/test_utils");
29
+ const types_1 = require("@icure/test-setup/types");
30
+ const User_1 = require("../../../icc-api/model/User");
31
+ const TestStorage_1 = require("../../utils/TestStorage");
32
+ const TestCryptoStrategies_1 = require("../../utils/TestCryptoStrategies");
33
+ const icc_api_1 = require("../../../icc-api");
34
+ const chai_1 = require("chai");
35
+ const EntityShareRequest_1 = require("../../../icc-api/model/requests/EntityShareRequest");
36
+ var initMasterApi = test_utils_1.TestUtils.initMasterApi;
37
+ var RequestedPermissionEnum = EntityShareRequest_1.EntityShareRequest.RequestedPermissionEnum;
38
+ (0, test_utils_1.setLocalStorage)(fetch);
39
+ let env;
40
+ describe('Legacy delegations migration test', () => {
41
+ before(function () {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ this.timeout(600000);
44
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
45
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
46
+ });
47
+ });
48
+ /**
49
+ * Participants:
50
+ *
51
+ * A, B children hcp of P
52
+ * X, X2 are external hcps, not related to A/B/P.
53
+ */
54
+ // prettier-ignore
55
+ function createTestDataAndApis() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ // The following data was created for test purposes only and does not contain any real key / secrets.
58
+ const pId = (0, crypto_1.randomUUID)();
59
+ const pLogin = `parent-${(0, crypto_1.randomUUID)()}`;
60
+ const pPassword = (0, crypto_1.randomUUID)();
61
+ const pPrivateKey = '308204be020100300d06092a864886f70d0101010500048204a8308204a40201000282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001028201000e18c171b03dab58dd5830eff34a7080780b60d952b721eed8927292090b8e308f8dd6fba7a9b9ec929668f94b091b880198ffd84c2eede6d5a41ba779b24da9622687e76bac629f95efb3fbc56cd87289cc13fe058892c7f77ac18b815d1250b58dc7ff20f2f6a95dc7135926a79daca0fdbd1ed756d4c19be8447bd0a200e17419cdd90af54e3b204c1297054d61a6ba9183dfd280d571ee52ee3ed39959abb36ecf575429727d8130bfb070131a46b473a94798834707431bdd248e873d9a716cc469d7f21b545dc2eb21d892e8d94ee6544bd82e8112e697eeaecf6a01d31bffaaf37558aec381f8d12c8491ff77ce00a1da4e2fe6ddf4e5dd14fe1ef90102818100dd2b49e13111593e91a882ae522c1363e2b5e3a10e71c4599e32eec56d9d01682983232b582f2e0923dd107e259771382dd7ff738be31cbba5095153a636dd44e8b08f47e044bbf5814aebdcfed33f0a32fc2f62bf3a0ded9d8aed48fc8034debbf5399862ca2bac72d9d4ab70f90a6a246c6cf4a62c9cb887ea776dce57511902818100d61925b811da57c10e444528230bdb0156516b5ca9ff89a9e57da8373bf5911d009bf5e8a6ee0d40edb89f01e638a528ce592e27d3e7f2172ce373a3b510f2f5045a5dd9aa4ae28b088553a5d099f95611447df464da04168d88ba69751046229131b5a820f9215548de643a82a04ad062ddd74a2e2f30d88480b115c2aa372502818031e374dbce14aabbd9615870f7ea27498db717ac99b481e4f1316df8acbc10b82d3cfe6ee58a66e8fae4ffb664c65f6c9bb2b055a1054ed2e8ec4c23014838eb354db654313b6fe6760eaf5b7f43a961a4948c1fcb20ce497e12fb694e43a12968de6cea79c63ec9bc72746d63a3597d0dd04357803069fd99f302938b4ad8e902818100c167f835ff12b2417924dd2074006ab81b84f3aac2fb501e056d6d3f704fd6e64f3d9478b60bc83746488883cbb8922279be003f0463bcc388ce741188292681868c27c9d0d7532d6be61d7966272221c8f9899af45c2a63413a29c3c8778a1401fbd8f167d00677a79b1709f024e350ba6f52e3f532b63a72005b789fe0ea6d02818100cd0855c641e6294a1c05667f043eedf539c38bbd357dd20dacb182c96455593c689eafc7844d2ba8cd86ce77a3f3151aa261434cdb4d21367c9c62f73289aecb2719de0aca9857365eb16cc56bffbd9b28835eaa4499971996e63306bfdfea35c86179bd749992501aa6c0f45c0123ef6a8a3bb4344c198a0046b94c3bf506f5'; // pragma: allowlist secret
62
+ const pHcpBase = {
63
+ id: pId,
64
+ lastName: '8ed642',
65
+ firstName: 'c9d727',
66
+ publicKey: '30820122300d06092a864886f70d01010105000382010f003082010a0282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001', // pragma: allowlist secret
67
+ };
68
+ const pUserBase = {
69
+ id: (0, crypto_1.randomUUID)(),
70
+ name: pLogin,
71
+ status: User_1.User.StatusEnum.ACTIVE,
72
+ login: pLogin,
73
+ passwordHash: pPassword,
74
+ healthcarePartyId: pId,
75
+ email: pLogin,
76
+ };
77
+ const aId = (0, crypto_1.randomUUID)();
78
+ const aLogin = `childA-${(0, crypto_1.randomUUID)()}`;
79
+ const aPassword = (0, crypto_1.randomUUID)();
80
+ const aPrivateKey = '308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced020301000102820100129e03bed566d42be33a2ea48dcabfd37cc004c13c98e3af3beb8eaee9ebed2d0f2316f667e3d8772b35c3b8eab9cea0e795f356c81d63dd5edacbd325646d7a837367220149e71a97751c73857609ca1cabdea898509508cb49beb88e7c63099ef79bf36302381dfa6e833f2e6496fa8e1df81c04db7971a335d87f7c7660ba6ffb6cc0b3089086df855145b69dba0404ae77b1d533693030e8aa17b851c313d9de7b98a2cd5333fbd1b7d9d7d8d4296c2fc794a50003438eccf0d6dc0a0b34c2695d4f40fa8a5d2de12d5579bc3b33208227cff350413702643f31e0d02317da8165c3f7f1b6a18f00fcea5d981904cb1f5c2bd85d30da963184611f0a06d902818100f6860c1d1c53ad2489bc5e967365e226b25bf292c9ca4f01bbee6d7665f544834f553275e6dc373ed69c942d2e889be2537ae5f5672988c63993bc4f95cbb3dc25b3b8cdf7e274b61532b0e101df22cd54735c2d3f353a4d2d48a1e8dcf11089545b3d8b37f4fa2d3d91129d92e67d9937b065a0bf07c7801df87dd8c1c95f4702818100f2261c810d62345f806345b909e8b1d399d961d5f1bd3c580c96c44ba2e6e532ac93f12cdb25fb6fa9e7a823052c2983611b6c359df98be6c7d0e6377a27cd7f0f67f4568fb72c42d7c3bb13afead3b25a30b7827c1f059d9f75c939fc8608afe2882fdeeb3c292ba45647f373c8ff5719c6da1152c94871b722e8129851a42b028181008fe65945d8d6233833ca27f06c75e957ab3f2ece6e49d06a73b7ce5f914e64eabd313f1e415f044482e3ad3ede6dd188803039f15081971c1659dd4f1b62679fb6c63cb6c5de834012099fe407c2a73ef1efd0bb7cace6564c7b9c3f2050fad51ecf8f92275cb1781cfb04c1c41114f98ddf42c35d1efe5e13a08c5d2d690d5b02818033d7a2fca22fe744970929f13ec4d9e592a7aec18e3ad483895671fa3b8b3180d2dfed9f8bdfaae032410d8749e1359612213bde92cecd7c0045a234386bf31c03e15eb7759762db80b440062c009b8830b50364e54c02f8c71e0191ef9586a099604cd76e07784d06a70e4a79fc8b664b777e527d25e8e3a7b0ca7cc8ad99f70281803b9df4b2e66d849b269300fe42c3136d929fdc184d51283a9fe25772a796ed710b475e85a4e442519a207eeb66e0d89d552798a9b2eb2ebb329109cf4fbce35feba75025a157b57c98776dbe9f04c8937e5cd34021b68ffac95c23c3129967a3aa82ddda35098ba55958e3531fa226825a2685e1ce94353a22a03a1eb9b1a9a0'; // pragma: allowlist secret
81
+ const aHcpBase = {
82
+ id: aId,
83
+ lastName: '6144e2',
84
+ firstName: '6ca3b4',
85
+ parentId: pId,
86
+ aesExchangeKeys: {
87
+ '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001': // pragma: allowlist secret
88
+ {
89
+ [pId]: {
90
+ '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret
91
+ '4ca457e66519a3f403e089f56f3838a18af16e47029d33ca40eca6a24d1f213809851920b8d159e3879284e5e8d1e0c64be874261d3e0003c43a21ddab9301f8a54161911d3bebe3b1ee6d2a040ec88caa484b6ffd46200bc6eb1a767f309e960f977b9e82d81a0b4961b517e89f24cbc9d0133f955a8d6f792486b1e5dcd9088fe5ecc07b11230b1960013c914041e5de3e9b3c37fa4c2a44dcf2136aae57e000acfe824dacd900bf6be5f6b4f3c41534237a01e14d728065c586dbfd3eeb81ad070218be3e2f70757e9ca5d940afa0b67e02d41e68c1c10935157bc6bd3c06eda95f23c10ca60b649a5ec32903c2a995c0b97fb40cdf454c53621304b0d5b0',
92
+ b59b1e44efebd4db537ced0203010001: '50864963c90cc12704b35ec6cd15ee40a2f4fd4dcb1cf287612346eab4df139008adef1c6d778e35aa7cb58251ff34d6bf1b0faa59d5453c328fa381b175143f41ce66463146b9a02d546cea0065bf62d1ce58e27a8d3bb8bebbb97b76c7e0d7a67b481fdc5082e99aa0521026eb89344b9404da04b0a69988e03724421747e47ab544ed2c55d0424f2837e641f9df4f4ece731e38f9a16d056d9fcf442730c50b3cabcdfbd8241677648639af75198bd30ded0f0fa2db0f8ce80cf86350cef278ce1c7a5426262ceebcc6be5579892d8e066763e216e1592f3f5faa13c561f73400549f5ba2bd618fb308ef99d52cc360ce30988af058caca8c23113933f588', // pragma: allowlist secret
93
+ },
94
+ [aId]: {
95
+ b59b1e44efebd4db537ced0203010001: '189ab5f91d1401fe4c8d2be8e044dcb80211fbf1f310d154a21e32b2b7c0cca715178b42a9a5bbd136b81eed1158da5c8e600e265b38c2b608127b343f0d8da301d80eb24a620ed64bec091771a092a2072a922c2852de55942cc99ae0f9c609150c9621cbaf27740105b28e33668ad0a960c13f884029bb1c8253d646b503ac597f8dbb6ce79b64e7b3929b3a3b649805fb327c2d855f47947e8d5dbf9aa4a0da56b9c1030e9fb1f415d0ee48d91d11c320d1bcba9b96a50574ab406f84629edbb86c68ca548d9dcdd08b4d63c93b3d654e810baaf0782068bc91934fb19f9ab46d940dd3d3e27fc6ac1bcd47440f098d97a9b454df929ba60ae0aa5efe7861', // pragma: allowlist secret
96
+ },
97
+ },
98
+ },
99
+ publicKey: '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001', // pragma: allowlist secret
100
+ };
101
+ const aUserBase = {
102
+ id: (0, crypto_1.randomUUID)(),
103
+ name: aLogin,
104
+ status: User_1.User.StatusEnum.ACTIVE,
105
+ login: aLogin,
106
+ passwordHash: aPassword,
107
+ healthcarePartyId: aId,
108
+ autoDelegations: {
109
+ all: [pId],
110
+ },
111
+ email: aLogin,
112
+ };
113
+ const bId = (0, crypto_1.randomUUID)();
114
+ const bLogin = `childB-${(0, crypto_1.randomUUID)()}`;
115
+ const bPassword = (0, crypto_1.randomUUID)();
116
+ const bPrivateKey = '308204bc020100300d06092a864886f70d0101010500048204a6308204a20201000282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001028201002a9bac7afc9ae5399f4242cf4b36110e9de8570e1f46704dd374cf4a8425c7115f9e022b59475b23336bf1b4208a1052a8e183217010d358c88a26fe75fc6242c1be45c696bf8dff8c53f838bef9a0ef9774e486bf15b27e12dbd69775b3a1bbb5410e303019fd1eb4efcd6c2fd2a5a5c53e6388466d6210f8ec4474ecb35c76d2c4269d3a585cdce972673c56818015b9f097ff528e26272b76810cb4f8a1ee5ea04ea26f4cf3c6f78b77c5f58d80628f513a4da76cc1e35a6867af1ab76fe0354e549340221d19bfe04783e34f84eca7bd80867134710adc0665a52eb689d2cf6ecb38ca77d84f4feb8c23539e92ac870b3175c174d8f5643aabc0e7ef3cd102818100ba44b38b24e28d9fb85279c0098b4505e0852ba88b54d2cb8b0e77368c1600bb40b4c0f6dee8b97788e082af0f9045dd54f05ee583fffabc473d16272d03c1aef301541176e7a95f948f8d77b6aad087c54f2de713909efdd5d90a8bbec61067172a97480ba844c25cf64a8b1f0698e2f4dd73af798dd8ab329f7f9bf9a0f9ff02818100d11781567bde00a256ac7ef2c4bf10a5b8b2ebab77c941b7665817f17aa496f166ecd89bb4c50c53d4e836b3369edc2f0f49e64f8dbe7ddaf0fb3898075f6e82ab2c69bc925368904ba459ce08a40ce621dceefa78b64d8eb68752d1cc2a53a1db9718ab1a8703333065cf9b8407174c18f8b085e4aebf32a5bf9b259a6bab71028180492352b04f025a039df75c70e80e7442b37ef6be8e3ef72a0ee6d62e67e0f7d68eb8aa9004c4b29659fb75b4d1529fec213ee4b4101981d54dcf91943e5b9c405a9069f7158e2ef625ba1c1d266f79c3e5d88a38927915c4aba4363cdae2a06c2a2f82093af28e5516f56a1da84809de0bb1ac8bf919963ada7cc039795218f70281802b0aceaa31f78263e8b9bbac580a08f04474388564b43e5df5a87ecd4bf4e3c9afe963b1b1e5ba62eb7a1e008866ed66969c1cd81592b82fc0d9c64dad7edcadf374c2137a7fc70fa532a0f603db59786a5223b3d5f399459e977eda0750534507823426cce02c2d76720ee9b1a5100baf3c4a8255900f75ea9ee5de38ca9f510281802c19faaa1e08ac6337c48af1529f8b8685d2582586986b180377aee8cf4eaadcdbb5869c6f994275b0ae3ecc6aa0ead81296ab9a96eecb44f14fcd9e50ef34d9725e97809b3ed2ed6105102c96ea55a096f292a8d9769c05779f303dc6ad3b30c3c9bea749d58636b3977c9c593557c048b2f82e90fead32b5b510966e548e7a'; // pragma: allowlist secret
117
+ const bHcpBase = {
118
+ id: bId,
119
+ lastName: '95ee22',
120
+ firstName: '2af696',
121
+ parentId: pId,
122
+ aesExchangeKeys: {
123
+ '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret
124
+ {
125
+ [pId]: {
126
+ '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret
127
+ '5e186cec6d6ddb277aa5421a345045f5f44aa125844e833529fccfeb3a002dd4aef78d84b5b8710ff0aa375436e2abdea07a2cb186cd914fa8b8fb86ab1201b109d802927b49517322ac6521600a123ee03d9383154b6f0fa0e99a8ca6e73e07ceed4aeb835649a850316c5585b2a69ac6703c7154f2db981913bac36a0cea515c70c505d1dc3a7e3a6db519cf7b68737a80ad102cc575959b08fbe327644e7d1b7da0737bfa6ededdd7bf0538fd3dc040ac57937bebdf3146a566c2619314935bc610e900b9c350fcf21a9b20c47f0ee25112578dc210b6b17c4cad9687d2bd9abab12f03f8b778b74186ac3c61d57058037d0e00903c74d2eaa8b2fdb90e3f',
128
+ '36108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret
129
+ '89764feb4d23d8313d58c0568088ecf9f320dd285eb762eaee8593a9ecc884a54e4eb6cd93a87f1383f345b94b8a7f1d20dda33d972ab4460aef742d44837648403234700a5a9f85032b025c533aebdc7bea07dec17c7a1737a51f873ec36c689a29b3314fa2d0f77d7e83e71e5a1de1392a6e92fb9881d811253f2bc00db0798e213899a85bcf0bafeaf8b972c40b1a0d1dd3109e6a8bc9309caa5ada9bc41ea62c72fbdf7cf49cbbe15cd048e6d614a4d65e09f5bed014975ea19c160e3754abd9031e8a41283fa369fa621685aee16c5a5d18a1811fde27869cb156a00fe28ae42c9ff498f2c3dd88a392ac9d68d9885556effe62850681fa8fbe5e02781f', // pragma: allowlist secret
130
+ },
131
+ },
132
+ },
133
+ publicKey: '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001', // pragma: allowlist secret
134
+ };
135
+ const bUserBase = {
136
+ id: (0, crypto_1.randomUUID)(),
137
+ name: bLogin,
138
+ status: User_1.User.StatusEnum.ACTIVE,
139
+ login: bLogin,
140
+ passwordHash: bPassword,
141
+ groupId: 'test-group',
142
+ healthcarePartyId: bId,
143
+ autoDelegations: {
144
+ all: [pId],
145
+ },
146
+ email: bLogin,
147
+ };
148
+ const patientConfidentialSecretId = '24cd8cf5-0958-4ee9-8e90-95f3d25a47d7';
149
+ const patientBase = {
150
+ id: (0, crypto_1.randomUUID)(),
151
+ firstName: 'John',
152
+ lastName: 'Doe',
153
+ delegations: {
154
+ [aId]: [
155
+ {
156
+ owner: aId,
157
+ delegatedTo: aId,
158
+ key: '4bd1316d494e858496f1d6c1200726cb76c7ff98fb47eddb1c0bf5b79712230db3f02bdf60599816e0601628ee349674a0509720e9972d87b2370b60bcbbb19adb2980bc1ab5bab8b9c8adc5516d39d0cf2d6c373fe7285ce0f1018058e52fcc',
159
+ tags: ['confidential'],
160
+ },
161
+ {
162
+ owner: aId,
163
+ delegatedTo: aId,
164
+ key: '6121912dea437ddaf92c41a43deba576976a2b7c10c1cbba79624634ded8bb5d0210db5e339e3e26d33e6e2d18d6b8acc91f8415e5ab488b9227f7c6f6f370873f1d5b5ff3afd28dfe6e47ed10b0cb435676a4db039469a50547f3e1e515fc63', // pragma: allowlist secret
165
+ },
166
+ ],
167
+ [pId]: [
168
+ {
169
+ owner: aId,
170
+ delegatedTo: pId,
171
+ key: '0b293a861d76b21928c6689fb80c373f16bfbe8269ef201b5af35ff4634e51af1c5d3c535c384efea3126acee3572b815db950c52298b1ee99868041641110100c51ad3bc6d0bafddd5021b50b8e0fd16c44f5fd05617eae4f5a00c090c0ccfb', // pragma: allowlist secret
172
+ },
173
+ ],
174
+ },
175
+ encryptionKeys: {
176
+ [aId]: [
177
+ {
178
+ owner: aId,
179
+ delegatedTo: aId,
180
+ key: '42e625cb8930ca763f6b604d08775b4231e9414fa953feeafbd7cfc6acc138bdbf5013aa211935f9f429a627db5d41efa617b2ae9d46f93d83db73b36dab7892c07b03408ee4ab50974b0d4081162b4e9a2a448ce00e35d05aac4d7e675e99b3', // pragma: allowlist secret
181
+ },
182
+ ],
183
+ [pId]: [
184
+ {
185
+ owner: aId,
186
+ delegatedTo: pId,
187
+ key: '194ee902b4780178fd88ffddd1e0744537ddf952d306dfe1123b14bec4405dc1f6b9aea7444cc74f5acca0d18062c0e12d7d9bb6c7b7bff27efb681c7e5ca52f25797f45207f63c13778637a40a541a2e33d79dc1660d7f898d69c92a93aedcf', // pragma: allowlist secret
188
+ },
189
+ ],
190
+ },
191
+ encryptedSelf: 'jgAFAlmd2QStXpOt3LnIhs4upJv2e10fp0u6/PburW7mq1r3vo/Q5/a4Yk7EWXG7oydMWb2i1UCCiNN80czGdA==', // pragma: allowlist secret
192
+ };
193
+ const testSetupApi = yield initMasterApi(env);
194
+ yield testSetupApi.healthcarePartyApi.createHealthcareParty(pHcpBase);
195
+ const pUser = yield testSetupApi.userApi.createUser(pUserBase);
196
+ yield testSetupApi.healthcarePartyApi.createHealthcareParty(aHcpBase);
197
+ const aUser = yield testSetupApi.userApi.createUser(aUserBase);
198
+ yield testSetupApi.healthcarePartyApi.createHealthcareParty(bHcpBase);
199
+ const bUser = yield testSetupApi.userApi.createUser(bUserBase);
200
+ const pStorage = yield (0, TestStorage_1.testStorageWithKeys)([
201
+ {
202
+ dataOwnerId: pHcpBase.id,
203
+ pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
204
+ },
205
+ ]);
206
+ const aStorage = yield (0, TestStorage_1.testStorageWithKeys)([
207
+ {
208
+ dataOwnerId: aHcpBase.id,
209
+ pairs: [{ keyPair: { privateKey: aPrivateKey, publicKey: aHcpBase.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
210
+ },
211
+ {
212
+ dataOwnerId: pHcpBase.id,
213
+ pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
214
+ },
215
+ ]);
216
+ const bStorage = yield (0, TestStorage_1.testStorageWithKeys)([
217
+ {
218
+ dataOwnerId: bHcpBase.id,
219
+ pairs: [{ keyPair: { privateKey: bPrivateKey, publicKey: bHcpBase.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
220
+ },
221
+ {
222
+ dataOwnerId: pHcpBase.id,
223
+ pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey }, shaVersion: icc_x_api_1.ShaVersion.Sha1 }],
224
+ },
225
+ ]);
226
+ const pApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: pLogin, password: pPassword }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
227
+ storage: pStorage.storage,
228
+ keyStorage: pStorage.keyStorage,
229
+ entryKeysFactory: pStorage.keyFactory,
230
+ disableParentKeysInitialisation: false,
231
+ });
232
+ const aApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: aLogin, password: aPassword }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
233
+ storage: aStorage.storage,
234
+ keyStorage: aStorage.keyStorage,
235
+ entryKeysFactory: aStorage.keyFactory,
236
+ disableParentKeysInitialisation: false,
237
+ });
238
+ const bApi = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: bLogin, password: bPassword }, new TestCryptoStrategies_1.TestCryptoStrategies(), crypto_1.webcrypto, fetch, {
239
+ storage: bStorage.storage,
240
+ keyStorage: bStorage.keyStorage,
241
+ entryKeysFactory: bStorage.keyFactory,
242
+ disableParentKeysInitialisation: false,
243
+ });
244
+ const xInfo = yield (0, test_utils_1.createNewHcpApi)(env);
245
+ const x2Info = yield (0, test_utils_1.createNewHcpApi)(env);
246
+ const apis = { a: aApi, b: bApi, p: pApi, x: xInfo.api, x2: x2Info.api };
247
+ const xUser = xInfo.user;
248
+ const xCredentials = xInfo.credentials;
249
+ const x2User = x2Info.user;
250
+ const x2Credentials = x2Info.credentials;
251
+ const patient = yield new icc_api_1.IccPatientApi(env.iCureUrl, {}, aApi.authApi.authenticationProvider, fetch).createPatient(patientBase);
252
+ const ids = {
253
+ a: aId,
254
+ b: bId,
255
+ p: pId,
256
+ x: xCredentials.dataOwnerId,
257
+ x2: x2Credentials.dataOwnerId,
258
+ };
259
+ console.log(JSON.stringify(ids, undefined, 2));
260
+ return {
261
+ apis,
262
+ ids,
263
+ users: {
264
+ a: aUser,
265
+ b: bUser,
266
+ p: pUser,
267
+ x: xUser,
268
+ x2: x2User,
269
+ },
270
+ patient,
271
+ patientConfidentialSecretId,
272
+ patientNote: 'This is just a test patient',
273
+ };
274
+ });
275
+ }
276
+ /*
277
+ * Entity E with legacy metadata created by A and shared with P.
278
+ * There is also a confidential secret id (known by A but not P).
279
+ * B wants to share with X as read only.
280
+ * Expected outcome:
281
+ * - A root secure delegation B->B
282
+ * - A delegation B->P
283
+ * - Through the delegation B->P A and P can access all the legacy metadata available to P (but not the confidential secret id known by A)
284
+ * - A delegation from B->X
285
+ * - Through B->X X can access only the shared information and has read access only
286
+ *
287
+ * Now A wants to share with X2.
288
+ * Expected outcome:
289
+ * - A new root secure delegation A->A is available, which gives access to the confidential secret id
290
+ * - A delegation A->X2 with the shared information.
291
+ * - Parents of the new delegation are the new A->A root delegation and the existing A->P delegation.
292
+ * - B and P still can't access the confidential secret id.
293
+ */
294
+ it('sharing data as a child of a parent with legacy access should work', () => __awaiter(void 0, void 0, void 0, function* () {
295
+ var _a, _b, _c, _d;
296
+ console.log('Creating test data');
297
+ const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = yield createTestDataAndApis();
298
+ console.log('Starting test');
299
+ const secretIdsKnownByA = new Set(yield apis.a.patientApi.decryptSecretIdsOf(patient));
300
+ const secretIdsKnownByB = new Set(yield apis.b.patientApi.decryptSecretIdsOf(patient));
301
+ (0, chai_1.expect)(secretIdsKnownByB.size).to.eq(1);
302
+ (0, chai_1.expect)(secretIdsKnownByB.has(patientConfidentialSecretId)).to.be.false;
303
+ (0, chai_1.expect)(secretIdsKnownByA.size).to.eq(2);
304
+ (0, chai_1.expect)(secretIdsKnownByA.has(patientConfidentialSecretId)).to.be.true;
305
+ (0, chai_1.expect)(secretIdsKnownByA.has([...secretIdsKnownByB][0])).to.be.true;
306
+ const sharedPatient = yield apis.b.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {
307
+ requestedPermissions: RequestedPermissionEnum.FULL_READ,
308
+ });
309
+ const secureDelegations = Object.values((_b = (_a = sharedPatient.securityMetadata) === null || _a === void 0 ? void 0 : _a.secureDelegations) !== null && _b !== void 0 ? _b : {});
310
+ (0, chai_1.expect)(secureDelegations).to.have.length(3);
311
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.b)).to.not.be.undefined;
312
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.p)).to.not.be.undefined;
313
+ const sharedPatientWithoutLegacyDetails = Object.assign(Object.assign({}, sharedPatient), { delegations: {}, encryptionKeys: {} });
314
+ (0, chai_1.expect)(yield apis.a.patientApi.getEncryptionKeysOf(sharedPatientWithoutLegacyDetails)).to.have.length(1);
315
+ (0, chai_1.expect)(yield apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB]);
316
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.x)).to.not.be.undefined;
317
+ (0, chai_1.expect)((yield apis.x.patientApi.getPatientWithUser(users.x, patient.id)).note).to.eq(patientNote);
318
+ (0, chai_1.expect)(yield apis.x.cryptoApi.xapi.hasWriteAccess({ entity: sharedPatient, type: icc_x_api_1.EntityWithDelegationTypeName.Patient })).to.be.false;
319
+ (0, chai_1.expect)(yield apis.x.patientApi.modifyPatientWithUser(users.x, Object.assign(Object.assign({}, sharedPatient), { firstName: 'New name' })).then(() => true, () => false)).to.be.false;
320
+ (0, chai_1.expect)(yield apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB]);
321
+ const sharedPatient2 = yield apis.a.patientApi.shareWith(ids.x2, sharedPatient, [...secretIdsKnownByB], {
322
+ requestedPermissions: RequestedPermissionEnum.FULL_READ,
323
+ });
324
+ const secureDelegations2 = Object.values((_d = (_c = sharedPatient2.securityMetadata) === null || _c === void 0 ? void 0 : _c.secureDelegations) !== null && _d !== void 0 ? _d : {});
325
+ (0, chai_1.expect)(secureDelegations2).to.have.length(5);
326
+ (0, chai_1.expect)(secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined;
327
+ const secureDelegationAtoX2 = secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.x2);
328
+ (0, chai_1.expect)(secureDelegationAtoX2).to.not.be.undefined;
329
+ (0, chai_1.expect)(secureDelegationAtoX2 === null || secureDelegationAtoX2 === void 0 ? void 0 : secureDelegationAtoX2.parentDelegations).to.have.length(2);
330
+ (0, chai_1.expect)(yield apis.b.patientApi.decryptSecretIdsOf(sharedPatient2)).to.have.members([...secretIdsKnownByB]);
331
+ }));
332
+ /*
333
+ * Entity E with legacy metadata created by A and shared with P.
334
+ * There is also a confidential secret id (known by A but not P).
335
+ * A wants to share with X as read only.
336
+ * Expected outcome:
337
+ * - A root secure delegation for A
338
+ * - A->A includes the confidential secret id known by A
339
+ * - A delegation from A to P
340
+ * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)
341
+ */
342
+ it('sharing data created with legacy api by the same user ', () => __awaiter(void 0, void 0, void 0, function* () {
343
+ var _e, _f;
344
+ console.log('Creating test data');
345
+ const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = yield createTestDataAndApis();
346
+ console.log('Starting test');
347
+ const secretIdsKnownByA = new Set(yield apis.a.patientApi.decryptSecretIdsOf(patient));
348
+ const secretIdsKnownByB = new Set(yield apis.b.patientApi.decryptSecretIdsOf(patient));
349
+ const sharedPatient = yield apis.a.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {
350
+ requestedPermissions: RequestedPermissionEnum.FULL_READ,
351
+ });
352
+ const secureDelegations = Object.values((_f = (_e = sharedPatient.securityMetadata) === null || _e === void 0 ? void 0 : _e.secureDelegations) !== null && _f !== void 0 ? _f : {});
353
+ (0, chai_1.expect)(secureDelegations).to.have.length(3);
354
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined;
355
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.p)).to.not.be.undefined;
356
+ (0, chai_1.expect)(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.x)).to.not.be.undefined;
357
+ const sharedPatientWithoutLegacyDetails = Object.assign(Object.assign({}, sharedPatient), { delegations: {}, encryptionKeys: {} });
358
+ console.log(yield apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails));
359
+ console.log(yield apis.b.patientApi.decryptSecretIdsOf(sharedPatient));
360
+ console.log(yield apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails));
361
+ console.log(yield apis.x.patientApi.decryptSecretIdsOf(sharedPatient));
362
+ (0, chai_1.expect)(yield apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByA]);
363
+ (0, chai_1.expect)(yield apis.b.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB]);
364
+ (0, chai_1.expect)(yield apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB]);
365
+ (0, chai_1.expect)(yield apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB]);
366
+ console.log(JSON.stringify(sharedPatient, undefined, 2));
367
+ }));
368
+ });
369
+ //# sourceMappingURL=legacy-metadata-migration-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-metadata-migration-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/legacy-metadata-migration-test.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;AAEH,kDAAuF;AACvF,mCAA8C;AAC9C,uDAA+G;AAC/G,mDAAmE;AACnE,sDAAkD;AAGlD,yDAA6D;AAC7D,2EAAuE;AACvE,8CAAgD;AAChD,+BAA6B;AAC7B,2FAAuF;AACvF,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAG3E,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,mCAAmC,EAA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* Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n\nimport { EntityWithDelegationTypeName, IcureApi, ShaVersion } from '../../../icc-x-api'\nimport { randomUUID, webcrypto } from 'crypto'\nimport { createNewHcpApi, getEnvironmentInitializer, setLocalStorage, TestUtils } from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { User } from '../../../icc-api/model/User'\nimport { HealthcareParty } from '../../../icc-api/model/HealthcareParty'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { IccPatientApi } from '../../../icc-api'\nimport { expect } from 'chai'\nimport { EntityShareRequest } from '../../../icc-api/model/requests/EntityShareRequest'\nimport initMasterApi = TestUtils.initMasterApi\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegationsSecurityMetadataDecryptor } from '../../../icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor'\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Legacy delegations migration test', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n /**\n * Participants:\n *\n * A, B children hcp of P\n * X, X2 are external hcps, not related to A/B/P.\n */\n // prettier-ignore\n async function createTestDataAndApis(): Promise<{\n patientConfidentialSecretId: string\n apis: { a: IcureApi; b: IcureApi; p: IcureApi; x: IcureApi; x2: IcureApi }\n users: { a: User; b: User; p: User; x: User; x2: User }\n patient: Patient\n patientNote: string\n ids: { p: string; a: string; b: string; x: string; x2: string }\n }> {\n // The following data was created for test purposes only and does not contain any real key / secrets.\n const pId = randomUUID()\n const pLogin = `parent-${randomUUID()}`\n const pPassword = randomUUID()\n const pPrivateKey =\n '308204be020100300d06092a864886f70d0101010500048204a8308204a40201000282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001028201000e18c171b03dab58dd5830eff34a7080780b60d952b721eed8927292090b8e308f8dd6fba7a9b9ec929668f94b091b880198ffd84c2eede6d5a41ba779b24da9622687e76bac629f95efb3fbc56cd87289cc13fe058892c7f77ac18b815d1250b58dc7ff20f2f6a95dc7135926a79daca0fdbd1ed756d4c19be8447bd0a200e17419cdd90af54e3b204c1297054d61a6ba9183dfd280d571ee52ee3ed39959abb36ecf575429727d8130bfb070131a46b473a94798834707431bdd248e873d9a716cc469d7f21b545dc2eb21d892e8d94ee6544bd82e8112e697eeaecf6a01d31bffaaf37558aec381f8d12c8491ff77ce00a1da4e2fe6ddf4e5dd14fe1ef90102818100dd2b49e13111593e91a882ae522c1363e2b5e3a10e71c4599e32eec56d9d01682983232b582f2e0923dd107e259771382dd7ff738be31cbba5095153a636dd44e8b08f47e044bbf5814aebdcfed33f0a32fc2f62bf3a0ded9d8aed48fc8034debbf5399862ca2bac72d9d4ab70f90a6a246c6cf4a62c9cb887ea776dce57511902818100d61925b811da57c10e444528230bdb0156516b5ca9ff89a9e57da8373bf5911d009bf5e8a6ee0d40edb89f01e638a528ce592e27d3e7f2172ce373a3b510f2f5045a5dd9aa4ae28b088553a5d099f95611447df464da04168d88ba69751046229131b5a820f9215548de643a82a04ad062ddd74a2e2f30d88480b115c2aa372502818031e374dbce14aabbd9615870f7ea27498db717ac99b481e4f1316df8acbc10b82d3cfe6ee58a66e8fae4ffb664c65f6c9bb2b055a1054ed2e8ec4c23014838eb354db654313b6fe6760eaf5b7f43a961a4948c1fcb20ce497e12fb694e43a12968de6cea79c63ec9bc72746d63a3597d0dd04357803069fd99f302938b4ad8e902818100c167f835ff12b2417924dd2074006ab81b84f3aac2fb501e056d6d3f704fd6e64f3d9478b60bc83746488883cbb8922279be003f0463bcc388ce741188292681868c27c9d0d7532d6be61d7966272221c8f9899af45c2a63413a29c3c8778a1401fbd8f167d00677a79b1709f024e350ba6f52e3f532b63a72005b789fe0ea6d02818100cd0855c641e6294a1c05667f043eedf539c38bbd357dd20dacb182c96455593c689eafc7844d2ba8cd86ce77a3f3151aa261434cdb4d21367c9c62f73289aecb2719de0aca9857365eb16cc56bffbd9b28835eaa4499971996e63306bfdfea35c86179bd749992501aa6c0f45c0123ef6a8a3bb4344c198a0046b94c3bf506f5' // pragma: allowlist secret\n const pHcpBase: HealthcareParty = {\n id: pId,\n lastName: '8ed642',\n firstName: 'c9d727',\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100b8f7e992be3973d42954ca27da89259961c93cca31c6494b074f6f5992ce7ba1d95fdfaf043d5047b6e492c735d68344e0348f08683f1dae728d1e86c439c8498613ec7c8fb54930afbb9f45c74f4d312ecf5d989cb2edd96f887551792094ddd2d18a4c2dc2107c9b044b755f93f8d63e956e1ff0299fa9ed190845f7f5f69dc510df005bd929fb4fed33b30d6e699e0632485cc4180cf5a130357cf64233a680a1a1cc6b6761188192734916cabda14bb954ba3807b84c92f078fe83eea31260390356a8d53853148191144a4584fef02d28bc8353d3c33a87b156396e5fcb7994165da48138db3a3b986fe1c12d46273a218af63b42514690fbb161a5179d0203010001', // pragma: allowlist secret\n }\n const pUserBase: User = {\n id: randomUUID(),\n name: pLogin,\n status: User.StatusEnum.ACTIVE,\n login: pLogin,\n passwordHash: pPassword,\n healthcarePartyId: pId,\n email: pLogin,\n }\n const aId = randomUUID()\n const aLogin = `childA-${randomUUID()}`\n const aPassword = randomUUID()\n const aPrivateKey =\n '308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced020301000102820100129e03bed566d42be33a2ea48dcabfd37cc004c13c98e3af3beb8eaee9ebed2d0f2316f667e3d8772b35c3b8eab9cea0e795f356c81d63dd5edacbd325646d7a837367220149e71a97751c73857609ca1cabdea898509508cb49beb88e7c63099ef79bf36302381dfa6e833f2e6496fa8e1df81c04db7971a335d87f7c7660ba6ffb6cc0b3089086df855145b69dba0404ae77b1d533693030e8aa17b851c313d9de7b98a2cd5333fbd1b7d9d7d8d4296c2fc794a50003438eccf0d6dc0a0b34c2695d4f40fa8a5d2de12d5579bc3b33208227cff350413702643f31e0d02317da8165c3f7f1b6a18f00fcea5d981904cb1f5c2bd85d30da963184611f0a06d902818100f6860c1d1c53ad2489bc5e967365e226b25bf292c9ca4f01bbee6d7665f544834f553275e6dc373ed69c942d2e889be2537ae5f5672988c63993bc4f95cbb3dc25b3b8cdf7e274b61532b0e101df22cd54735c2d3f353a4d2d48a1e8dcf11089545b3d8b37f4fa2d3d91129d92e67d9937b065a0bf07c7801df87dd8c1c95f4702818100f2261c810d62345f806345b909e8b1d399d961d5f1bd3c580c96c44ba2e6e532ac93f12cdb25fb6fa9e7a823052c2983611b6c359df98be6c7d0e6377a27cd7f0f67f4568fb72c42d7c3bb13afead3b25a30b7827c1f059d9f75c939fc8608afe2882fdeeb3c292ba45647f373c8ff5719c6da1152c94871b722e8129851a42b028181008fe65945d8d6233833ca27f06c75e957ab3f2ece6e49d06a73b7ce5f914e64eabd313f1e415f044482e3ad3ede6dd188803039f15081971c1659dd4f1b62679fb6c63cb6c5de834012099fe407c2a73ef1efd0bb7cace6564c7b9c3f2050fad51ecf8f92275cb1781cfb04c1c41114f98ddf42c35d1efe5e13a08c5d2d690d5b02818033d7a2fca22fe744970929f13ec4d9e592a7aec18e3ad483895671fa3b8b3180d2dfed9f8bdfaae032410d8749e1359612213bde92cecd7c0045a234386bf31c03e15eb7759762db80b440062c009b8830b50364e54c02f8c71e0191ef9586a099604cd76e07784d06a70e4a79fc8b664b777e527d25e8e3a7b0ca7cc8ad99f70281803b9df4b2e66d849b269300fe42c3136d929fdc184d51283a9fe25772a796ed710b475e85a4e442519a207eeb66e0d89d552798a9b2eb2ebb329109cf4fbce35feba75025a157b57c98776dbe9f04c8937e5cd34021b68ffac95c23c3129967a3aa82ddda35098ba55958e3531fa226825a2685e1ce94353a22a03a1eb9b1a9a0' // pragma: allowlist secret\n const aHcpBase: HealthcareParty = {\n id: aId,\n lastName: '6144e2',\n firstName: '6ca3b4',\n parentId: pId,\n aesExchangeKeys: {\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001': // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '4ca457e66519a3f403e089f56f3838a18af16e47029d33ca40eca6a24d1f213809851920b8d159e3879284e5e8d1e0c64be874261d3e0003c43a21ddab9301f8a54161911d3bebe3b1ee6d2a040ec88caa484b6ffd46200bc6eb1a767f309e960f977b9e82d81a0b4961b517e89f24cbc9d0133f955a8d6f792486b1e5dcd9088fe5ecc07b11230b1960013c914041e5de3e9b3c37fa4c2a44dcf2136aae57e000acfe824dacd900bf6be5f6b4f3c41534237a01e14d728065c586dbfd3eeb81ad070218be3e2f70757e9ca5d940afa0b67e02d41e68c1c10935157bc6bd3c06eda95f23c10ca60b649a5ec32903c2a995c0b97fb40cdf454c53621304b0d5b0', // pragma: allowlist secret\n b59b1e44efebd4db537ced0203010001:\n '50864963c90cc12704b35ec6cd15ee40a2f4fd4dcb1cf287612346eab4df139008adef1c6d778e35aa7cb58251ff34d6bf1b0faa59d5453c328fa381b175143f41ce66463146b9a02d546cea0065bf62d1ce58e27a8d3bb8bebbb97b76c7e0d7a67b481fdc5082e99aa0521026eb89344b9404da04b0a69988e03724421747e47ab544ed2c55d0424f2837e641f9df4f4ece731e38f9a16d056d9fcf442730c50b3cabcdfbd8241677648639af75198bd30ded0f0fa2db0f8ce80cf86350cef278ce1c7a5426262ceebcc6be5579892d8e066763e216e1592f3f5faa13c561f73400549f5ba2bd618fb308ef99d52cc360ce30988af058caca8c23113933f588', // pragma: allowlist secret\n },\n [aId]: {\n b59b1e44efebd4db537ced0203010001:\n '189ab5f91d1401fe4c8d2be8e044dcb80211fbf1f310d154a21e32b2b7c0cca715178b42a9a5bbd136b81eed1158da5c8e600e265b38c2b608127b343f0d8da301d80eb24a620ed64bec091771a092a2072a922c2852de55942cc99ae0f9c609150c9621cbaf27740105b28e33668ad0a960c13f884029bb1c8253d646b503ac597f8dbb6ce79b64e7b3929b3a3b649805fb327c2d855f47947e8d5dbf9aa4a0da56b9c1030e9fb1f415d0ee48d91d11c320d1bcba9b96a50574ab406f84629edbb86c68ca548d9dcdd08b4d63c93b3d654e810baaf0782068bc91934fb19f9ab46d940dd3d3e27fc6ac1bcd47440f098d97a9b454df929ba60ae0aa5efe7861', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100e92f6acc40dbf839fa26e14579fcb68b5e8530f7bfada96338d4f986936cf177e242a458cb1811c2c49c469fa84d2c6ba0c0f34ba6e28babfaff863ff9f3938741d4a41b936143adcff5b396ce12f253e1af424ebd75aa133bdf606b1be51142ee4f5310f4ab46b7a7d706034028f81c462a758f0243d3791d27758bcc8af8010116ee70f1e61eb4526d05d245d631459974eea86b500ad0083e7f196ab9c4926487d92aa2849878f2e4093691d0539b9e880ff6717dbe5e7903141aaf796d74100c42c4d33ac2356df7e3e037accf4495c05f2caf57ae47130b1833f95397e1e9324f2abc1e6af56d7297cf48ea2ba0d990cff2f3b59b1e44efebd4db537ced0203010001', // pragma: allowlist secret\n }\n const aUserBase: User = {\n id: randomUUID(),\n name: aLogin,\n status: User.StatusEnum.ACTIVE,\n login: aLogin,\n passwordHash: aPassword,\n healthcarePartyId: aId,\n autoDelegations: {\n all: [pId],\n },\n email: aLogin,\n }\n const bId = randomUUID()\n const bLogin = `childB-${randomUUID()}`\n const bPassword = randomUUID()\n const bPrivateKey =\n '308204bc020100300d06092a864886f70d0101010500048204a6308204a20201000282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001028201002a9bac7afc9ae5399f4242cf4b36110e9de8570e1f46704dd374cf4a8425c7115f9e022b59475b23336bf1b4208a1052a8e183217010d358c88a26fe75fc6242c1be45c696bf8dff8c53f838bef9a0ef9774e486bf15b27e12dbd69775b3a1bbb5410e303019fd1eb4efcd6c2fd2a5a5c53e6388466d6210f8ec4474ecb35c76d2c4269d3a585cdce972673c56818015b9f097ff528e26272b76810cb4f8a1ee5ea04ea26f4cf3c6f78b77c5f58d80628f513a4da76cc1e35a6867af1ab76fe0354e549340221d19bfe04783e34f84eca7bd80867134710adc0665a52eb689d2cf6ecb38ca77d84f4feb8c23539e92ac870b3175c174d8f5643aabc0e7ef3cd102818100ba44b38b24e28d9fb85279c0098b4505e0852ba88b54d2cb8b0e77368c1600bb40b4c0f6dee8b97788e082af0f9045dd54f05ee583fffabc473d16272d03c1aef301541176e7a95f948f8d77b6aad087c54f2de713909efdd5d90a8bbec61067172a97480ba844c25cf64a8b1f0698e2f4dd73af798dd8ab329f7f9bf9a0f9ff02818100d11781567bde00a256ac7ef2c4bf10a5b8b2ebab77c941b7665817f17aa496f166ecd89bb4c50c53d4e836b3369edc2f0f49e64f8dbe7ddaf0fb3898075f6e82ab2c69bc925368904ba459ce08a40ce621dceefa78b64d8eb68752d1cc2a53a1db9718ab1a8703333065cf9b8407174c18f8b085e4aebf32a5bf9b259a6bab71028180492352b04f025a039df75c70e80e7442b37ef6be8e3ef72a0ee6d62e67e0f7d68eb8aa9004c4b29659fb75b4d1529fec213ee4b4101981d54dcf91943e5b9c405a9069f7158e2ef625ba1c1d266f79c3e5d88a38927915c4aba4363cdae2a06c2a2f82093af28e5516f56a1da84809de0bb1ac8bf919963ada7cc039795218f70281802b0aceaa31f78263e8b9bbac580a08f04474388564b43e5df5a87ecd4bf4e3c9afe963b1b1e5ba62eb7a1e008866ed66969c1cd81592b82fc0d9c64dad7edcadf374c2137a7fc70fa532a0f603db59786a5223b3d5f399459e977eda0750534507823426cce02c2d76720ee9b1a5100baf3c4a8255900f75ea9ee5de38ca9f510281802c19faaa1e08ac6337c48af1529f8b8685d2582586986b180377aee8cf4eaadcdbb5869c6f994275b0ae3ecc6aa0ead81296ab9a96eecb44f14fcd9e50ef34d9725e97809b3ed2ed6105102c96ea55a096f292a8d9769c05779f303dc6ad3b30c3c9bea749d58636b3977c9c593557c048b2f82e90fead32b5b510966e548e7a' // pragma: allowlist secret\n const bHcpBase: HealthcareParty = {\n id: bId,\n lastName: '95ee22',\n firstName: '2af696',\n parentId: pId,\n aesExchangeKeys: {\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret\n {\n [pId]: {\n '3b42514690fbb161a5179d0203010001': // pragma: allowlist secret\n '5e186cec6d6ddb277aa5421a345045f5f44aa125844e833529fccfeb3a002dd4aef78d84b5b8710ff0aa375436e2abdea07a2cb186cd914fa8b8fb86ab1201b109d802927b49517322ac6521600a123ee03d9383154b6f0fa0e99a8ca6e73e07ceed4aeb835649a850316c5585b2a69ac6703c7154f2db981913bac36a0cea515c70c505d1dc3a7e3a6db519cf7b68737a80ad102cc575959b08fbe327644e7d1b7da0737bfa6ededdd7bf0538fd3dc040ac57937bebdf3146a566c2619314935bc610e900b9c350fcf21a9b20c47f0ee25112578dc210b6b17c4cad9687d2bd9abab12f03f8b778b74186ac3c61d57058037d0e00903c74d2eaa8b2fdb90e3f', // pragma: allowlist secret\n '36108978e3371e9aa0ae8f0203010001': // pragma: allowlist secret\n '89764feb4d23d8313d58c0568088ecf9f320dd285eb762eaee8593a9ecc884a54e4eb6cd93a87f1383f345b94b8a7f1d20dda33d972ab4460aef742d44837648403234700a5a9f85032b025c533aebdc7bea07dec17c7a1737a51f873ec36c689a29b3314fa2d0f77d7e83e71e5a1de1392a6e92fb9881d811253f2bc00db0798e213899a85bcf0bafeaf8b972c40b1a0d1dd3109e6a8bc9309caa5ada9bc41ea62c72fbdf7cf49cbbe15cd048e6d614a4d65e09f5bed014975ea19c160e3754abd9031e8a41283fa369fa621685aee16c5a5d18a1811fde27869cb156a00fe28ae42c9ff498f2c3dd88a392ac9d68d9885556effe62850681fa8fbe5e02781f', // pragma: allowlist secret\n },\n },\n },\n publicKey:\n '30820122300d06092a864886f70d01010105000382010f003082010a0282010100982330dc464b3e9c583affbfece209976bc045f07b22fb44bcb0ebc27bc9d8406b54e380d195e107c1728499a64012b3251c1c85a2516e73b89a07b1929f0c12d44828677135082e8170b9831dd4ff9e988d098731eadd1443813cb5f6af2fe4c2a2706ba6aeb5bb6bb7889be51eebd83bebbb2a0b55a6d69fdeb66894af47edd6f82a8d30629814b82f17cfd1ef75f47d192eb9577c58f14a5e0d2782b13b796b5a3be780a38b0f69f3d00179d13cc23fcec1e919ac05d88c08c693c711384ad9fc7a21ed28d0e5d3865c15db239a5d727d4c52a344975c97379cc5a195ff4f8c1aacbaa67d6d0fd358b6b5d1a4d0575bc57b2d7736108978e3371e9aa0ae8f0203010001', // pragma: allowlist secret\n }\n const bUserBase: User = {\n id: randomUUID(),\n name: bLogin,\n status: User.StatusEnum.ACTIVE,\n login: bLogin,\n passwordHash: bPassword,\n groupId: 'test-group',\n healthcarePartyId: bId,\n autoDelegations: {\n all: [pId],\n },\n email: bLogin,\n }\n const patientConfidentialSecretId = '24cd8cf5-0958-4ee9-8e90-95f3d25a47d7'\n const patientBase: Patient = {\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Doe',\n delegations: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '4bd1316d494e858496f1d6c1200726cb76c7ff98fb47eddb1c0bf5b79712230db3f02bdf60599816e0601628ee349674a0509720e9972d87b2370b60bcbbb19adb2980bc1ab5bab8b9c8adc5516d39d0cf2d6c373fe7285ce0f1018058e52fcc', // pragma: allowlist secret\n tags: ['confidential'],\n },\n {\n owner: aId,\n delegatedTo: aId,\n key: '6121912dea437ddaf92c41a43deba576976a2b7c10c1cbba79624634ded8bb5d0210db5e339e3e26d33e6e2d18d6b8acc91f8415e5ab488b9227f7c6f6f370873f1d5b5ff3afd28dfe6e47ed10b0cb435676a4db039469a50547f3e1e515fc63', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '0b293a861d76b21928c6689fb80c373f16bfbe8269ef201b5af35ff4634e51af1c5d3c535c384efea3126acee3572b815db950c52298b1ee99868041641110100c51ad3bc6d0bafddd5021b50b8e0fd16c44f5fd05617eae4f5a00c090c0ccfb', // pragma: allowlist secret\n },\n ],\n },\n encryptionKeys: {\n [aId]: [\n {\n owner: aId,\n delegatedTo: aId,\n key: '42e625cb8930ca763f6b604d08775b4231e9414fa953feeafbd7cfc6acc138bdbf5013aa211935f9f429a627db5d41efa617b2ae9d46f93d83db73b36dab7892c07b03408ee4ab50974b0d4081162b4e9a2a448ce00e35d05aac4d7e675e99b3', // pragma: allowlist secret\n },\n ],\n [pId]: [\n {\n owner: aId,\n delegatedTo: pId,\n key: '194ee902b4780178fd88ffddd1e0744537ddf952d306dfe1123b14bec4405dc1f6b9aea7444cc74f5acca0d18062c0e12d7d9bb6c7b7bff27efb681c7e5ca52f25797f45207f63c13778637a40a541a2e33d79dc1660d7f898d69c92a93aedcf', // pragma: allowlist secret\n },\n ],\n },\n encryptedSelf: 'jgAFAlmd2QStXpOt3LnIhs4upJv2e10fp0u6/PburW7mq1r3vo/Q5/a4Yk7EWXG7oydMWb2i1UCCiNN80czGdA==', // pragma: allowlist secret\n }\n\n const testSetupApi = await initMasterApi(env)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(pHcpBase)\n const pUser = await testSetupApi.userApi.createUser(pUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(aHcpBase)\n const aUser = await testSetupApi.userApi.createUser(aUserBase)\n await testSetupApi.healthcarePartyApi.createHealthcareParty(bHcpBase)\n const bUser = await testSetupApi.userApi.createUser(bUserBase)\n const pStorage = await testStorageWithKeys([\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const aStorage = await testStorageWithKeys([\n {\n dataOwnerId: aHcpBase.id!,\n pairs: [{ keyPair: { privateKey: aPrivateKey, publicKey: aHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const bStorage = await testStorageWithKeys([\n {\n dataOwnerId: bHcpBase.id!,\n pairs: [{ keyPair: { privateKey: bPrivateKey, publicKey: bHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n {\n dataOwnerId: pHcpBase.id!,\n pairs: [{ keyPair: { privateKey: pPrivateKey, publicKey: pHcpBase.publicKey! }, shaVersion: ShaVersion.Sha1 }],\n },\n ])\n const pApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: pLogin, password: pPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: pStorage.storage,\n keyStorage: pStorage.keyStorage,\n entryKeysFactory: pStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const aApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: aLogin, password: aPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: aStorage.storage,\n keyStorage: aStorage.keyStorage,\n entryKeysFactory: aStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const bApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: bLogin, password: bPassword },\n new TestCryptoStrategies(),\n webcrypto as any,\n fetch,\n {\n storage: bStorage.storage,\n keyStorage: bStorage.keyStorage,\n entryKeysFactory: bStorage.keyFactory,\n disableParentKeysInitialisation: false,\n }\n )\n const xInfo = await createNewHcpApi(env)\n const x2Info = await createNewHcpApi(env)\n const apis = { a: aApi, b: bApi, p: pApi, x: xInfo.api, x2: x2Info.api }\n const xUser = xInfo.user\n const xCredentials = xInfo.credentials\n const x2User = x2Info.user\n const x2Credentials = x2Info.credentials\n const patient = await new IccPatientApi(env.iCureUrl, {}, aApi.authApi.authenticationProvider, fetch).createPatient(patientBase)\n const ids = {\n a: aId,\n b: bId,\n p: pId,\n x: xCredentials.dataOwnerId,\n x2: x2Credentials.dataOwnerId,\n }\n console.log(JSON.stringify(ids, undefined, 2))\n return {\n apis,\n ids,\n users: {\n a: aUser,\n b: bUser,\n p: pUser,\n x: xUser,\n x2: x2User,\n },\n patient,\n patientConfidentialSecretId,\n patientNote: 'This is just a test patient',\n }\n }\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * B wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation B->B\n * - A delegation B->P\n * - Through the delegation B->P A and P can access all the legacy metadata available to P (but not the confidential secret id known by A)\n * - A delegation from B->X\n * - Through B->X X can access only the shared information and has read access only\n *\n * Now A wants to share with X2.\n * Expected outcome:\n * - A new root secure delegation A->A is available, which gives access to the confidential secret id\n * - A delegation A->X2 with the shared information.\n * - Parents of the new delegation are the new A->A root delegation and the existing A->P delegation.\n * - B and P still can't access the confidential secret id.\n */\n it('sharing data as a child of a parent with legacy access should work', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n expect(secretIdsKnownByB.size).to.eq(1)\n expect(secretIdsKnownByB.has(patientConfidentialSecretId)).to.be.false\n expect(secretIdsKnownByA.size).to.eq(2)\n expect(secretIdsKnownByA.has(patientConfidentialSecretId)).to.be.true\n expect(secretIdsKnownByA.has([...secretIdsKnownByB][0])).to.be.true\n const sharedPatient = await apis.b.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.b)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.p)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n expect(await apis.a.patientApi.getEncryptionKeysOf(sharedPatientWithoutLegacyDetails)).to.have.length(1)\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(secureDelegations.find((d) => d.delegator === ids.b && d.delegate === ids.x)).to.not.be.undefined\n expect((await apis.x.patientApi.getPatientWithUser(users.x, patient.id!)).note).to.eq(patientNote)\n expect(await apis.x.cryptoApi.xapi.hasWriteAccess({ entity: sharedPatient, type: EntityWithDelegationTypeName.Patient })).to.be.false\n expect(\n await apis.x.patientApi.modifyPatientWithUser(users.x, { ...sharedPatient, firstName: 'New name' }).then(\n () => true,\n () => false\n )\n ).to.be.false\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n const sharedPatient2 = await apis.a.patientApi.shareWith(ids.x2, sharedPatient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations2 = Object.values(sharedPatient2.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations2).to.have.length(5)\n expect(secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n const secureDelegationAtoX2 = secureDelegations2.find((d) => d.delegator === ids.a && d.delegate === ids.x2)\n expect(secureDelegationAtoX2).to.not.be.undefined\n expect(secureDelegationAtoX2?.parentDelegations).to.have.length(2)\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient2)).to.have.members([...secretIdsKnownByB])\n })\n\n /*\n * Entity E with legacy metadata created by A and shared with P.\n * There is also a confidential secret id (known by A but not P).\n * A wants to share with X as read only.\n * Expected outcome:\n * - A root secure delegation for A\n * - A->A includes the confidential secret id known by A\n * - A delegation from A to P\n * - Through the delegation A->P A and P can access all the legacy metadata available to P (but not the confidential secret id)\n */\n it('sharing data created with legacy api by the same user ', async () => {\n console.log('Creating test data')\n const { apis, ids, patient, patientConfidentialSecretId, users, patientNote } = await createTestDataAndApis()\n console.log('Starting test')\n const secretIdsKnownByA = new Set(await apis.a.patientApi.decryptSecretIdsOf(patient))\n const secretIdsKnownByB = new Set(await apis.b.patientApi.decryptSecretIdsOf(patient))\n const sharedPatient = await apis.a.patientApi.shareWith(ids.x, patient, [...secretIdsKnownByB], {\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n })\n const secureDelegations = Object.values(sharedPatient.securityMetadata?.secureDelegations ?? {})\n expect(secureDelegations).to.have.length(3)\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.a)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.p)).to.not.be.undefined\n expect(secureDelegations.find((d) => d.delegator === ids.a && d.delegate === ids.x)).to.not.be.undefined\n const sharedPatientWithoutLegacyDetails: Patient = { ...sharedPatient, delegations: {}, encryptionKeys: {} }\n console.log(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient))\n console.log(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails))\n console.log(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient))\n expect(await apis.a.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByA])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n expect(await apis.b.patientApi.decryptSecretIdsOf(sharedPatientWithoutLegacyDetails)).to.have.members([...secretIdsKnownByB])\n expect(await apis.x.patientApi.decryptSecretIdsOf(sharedPatient)).to.have.members([...secretIdsKnownByB])\n console.log(JSON.stringify(sharedPatient, undefined, 2))\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,52 @@
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
+ const mocha_1 = require("mocha");
13
+ require("isomorphic-fetch");
14
+ const icc_x_api_1 = require("../../icc-x-api");
15
+ const chai_1 = require("chai");
16
+ const test_utils_1 = require("../utils/test_utils");
17
+ const types_1 = require("@icure/test-setup/types");
18
+ var initApi = test_utils_1.TestUtils.initApi;
19
+ (0, test_utils_1.setLocalStorage)(fetch);
20
+ let env;
21
+ (0, mocha_1.before)(function () {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ this.timeout(600000);
24
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
25
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
26
+ });
27
+ });
28
+ describe('icc-x-document-api Tests', () => {
29
+ it('Get and decrypt as json should work', () => __awaiter(void 0, void 0, void 0, function* () {
30
+ // Given
31
+ const { documentApi, userApi } = yield initApi(env, test_utils_1.hcp1Username);
32
+ const currUser = yield userApi.getCurrentUser();
33
+ const document = yield documentApi.createDocument(yield documentApi.newInstance(currUser, undefined, {}));
34
+ const obj = { test: 'test' };
35
+ yield documentApi.encryptAndSetDocumentAttachment(document, (0, icc_x_api_1.utf8_2ua)(JSON.stringify(obj)));
36
+ const decrypted = yield documentApi.getAndTryDecryptMainAttachmentAs(document, 'application/json');
37
+ (0, chai_1.expect)(decrypted).to.deep.equal(obj);
38
+ }));
39
+ it('Get and decrypt as string should work', () => __awaiter(void 0, void 0, void 0, function* () {
40
+ // Given
41
+ const { documentApi, userApi } = yield initApi(env, test_utils_1.hcp1Username);
42
+ const currUser = yield userApi.getCurrentUser();
43
+ const document = yield documentApi.createDocument(yield documentApi.newInstance(currUser, undefined, {}));
44
+ const obj = 'Test';
45
+ yield documentApi.encryptAndSetDocumentAttachment(document, (0, icc_x_api_1.utf8_2ua)(obj));
46
+ const decrypted = yield documentApi.getAndTryDecryptMainAttachmentAs(document, 'text/plain');
47
+ (0, chai_1.expect)(decrypted).to.deep.equal(obj);
48
+ const decryptedAsJson = yield documentApi.getAndTryDecryptMainAttachmentAs(document, 'application/json');
49
+ (0, chai_1.expect)(decryptedAsJson).to.be.undefined;
50
+ }));
51
+ });
52
+ //# sourceMappingURL=icc-document-x-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAS,EAAE;QACrD,QAAQ;QACR,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,GAAI,EAAE,yBAAY,CAAC,CAAA;QAElE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;QACzG,MAAM,GAAG,GAAG,MAAM,CAAA;QAClB,MAAM,WAAW,CAAC,+BAA+B,CAAC,QAAQ,EAAE,IAAA,oBAAQ,EAAC,GAAG,CAAC,CAAC,CAAA;QAC1E,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,gCAAgC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAC5F,IAAA,aAAM,EAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,gCAAgC,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAA;QACxG,IAAA,aAAM,EAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAA;IACzC,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { before } from 'mocha'\n\nimport 'isomorphic-fetch'\n\nimport { EntityWithDelegationTypeName, IccContactXApi, IccHelementXApi, IccPatientXApi, utf8_2ua } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { assert, expect } from 'chai'\nimport { randomUUID } from 'crypto'\nimport { getEnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { Code } from '../../icc-api/model/Code'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { Service } from '../../icc-api/model/Service'\nimport { Content } from '../../icc-api/model/Content'\nimport { User } from '../../icc-api/model/User'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { SubContact } from '../../icc-api/model/SubContact'\nimport { ServiceLink } from '../../icc-api/model/ServiceLink'\nimport { FilterChainService } from '../../icc-api/model/FilterChainService'\nimport { ServiceByHcPartyHealthElementIdsFilter } from '../../icc-x-api/filters/ServiceByHcPartyHealthElementIdsFilter'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { Measure } from '../../icc-api/model/Measure'\nimport initApi = TestUtils.initApi\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nbefore(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n})\n\ndescribe('icc-x-document-api Tests', () => {\n it('Get and decrypt as json should work', async () => {\n // Given\n const { documentApi, userApi } = await initApi(env!, hcp1Username)\n\n const currUser = await userApi.getCurrentUser()\n const document = await documentApi.createDocument(await documentApi.newInstance(currUser, undefined, {}))\n const obj = { test: 'test' }\n await documentApi.encryptAndSetDocumentAttachment(document, utf8_2ua(JSON.stringify(obj)))\n const decrypted = await documentApi.getAndTryDecryptMainAttachmentAs(document, 'application/json')\n expect(decrypted).to.deep.equal(obj)\n })\n\n it('Get and decrypt as string should work', async () => {\n // Given\n const { documentApi, userApi } = await initApi(env!, hcp1Username)\n\n const currUser = await userApi.getCurrentUser()\n const document = await documentApi.createDocument(await documentApi.newInstance(currUser, undefined, {}))\n const obj = 'Test'\n await documentApi.encryptAndSetDocumentAttachment(document, utf8_2ua(obj))\n const decrypted = await documentApi.getAndTryDecryptMainAttachmentAs(document, 'text/plain')\n expect(decrypted).to.deep.equal(obj)\n const decryptedAsJson = await documentApi.getAndTryDecryptMainAttachmentAs(document, 'application/json')\n expect(decryptedAsJson).to.be.undefined\n })\n})\n"]}
@@ -1,4 +1,5 @@
1
1
  import { IcureApi, IcureApiOptions } from '../../icc-x-api';
2
+ import { IcureApi as TestSetupApi } from '@icure/api';
2
3
  import { User } from '../../icc-api/model/User';
3
4
  import { TestVars, UserDetails } from '@icure/test-setup/types';
4
5
  import { EnvInitializer } from '@icure/test-setup/decorators';
@@ -59,6 +60,7 @@ export declare function createNewHcpWithoutKeyAndParentWithKey(env: TestVars, pr
59
60
  childDataOwnerId: string;
60
61
  childPassword: string;
61
62
  }>;
63
+ export declare function testSetupMasterApi(env: TestVars): Promise<TestSetupApi>;
62
64
  export type UserInManyGroupsDetails = {
63
65
  user1: User;
64
66
  user2: User;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  var _a, _b, _c, _d;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.itNoLite = exports.describeNoLite = exports.isLiteTest = exports.createUserInMultipleGroups = exports.createNewHcpWithoutKeyAndParentWithKey = exports.createHcpHierarchyApis = exports.createNewPatientApi = exports.createNewHcpApi = exports.getApiAndAddPrivateKeysForUser = exports.TestUtils = exports.getEnvironmentInitializer = exports.deviceUsername = exports.patUsername = exports.hcp3Username = exports.hcp2Username = exports.hcp1Username = exports.setLocalStorage = exports.getTempEmail = void 0;
13
+ exports.itNoLite = exports.describeNoLite = exports.isLiteTest = exports.createUserInMultipleGroups = exports.testSetupMasterApi = exports.createNewHcpWithoutKeyAndParentWithKey = exports.createHcpHierarchyApis = exports.createNewPatientApi = exports.createNewHcpApi = exports.getApiAndAddPrivateKeysForUser = exports.TestUtils = exports.getEnvironmentInitializer = exports.deviceUsername = exports.patUsername = exports.hcp3Username = exports.hcp2Username = exports.hcp1Username = exports.setLocalStorage = exports.getTempEmail = void 0;
14
14
  const icc_x_api_1 = require("../../icc-x-api");
15
15
  const os_1 = require("os");
16
16
  const util_1 = require("util");
@@ -337,6 +337,7 @@ function testSetupMasterApi(env) {
337
337
  },
338
338
  }, crypto_1.webcrypto, fetch);
339
339
  }
340
+ exports.testSetupMasterApi = testSetupMasterApi;
340
341
  function createUserInMultipleGroups(env) {
341
342
  return __awaiter(this, void 0, void 0, function* () {
342
343
  const primitives = new icc_x_api_1.CryptoPrimitives(crypto_1.webcrypto);