@icure/api 8.0.78 → 8.0.79

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.
@@ -25,6 +25,7 @@ export declare class ExchangeKeysManager {
25
25
  * @return all available exchange keys from the delegator-delegate pair.
26
26
  */
27
27
  getDecryptionExchangeKeysFor(delegatorId: string, delegateId: string): Promise<CryptoKey[]>;
28
+ private decryptChunk;
28
29
  /**
29
30
  * Reloads all exchange keys for the cache.
30
31
  */
@@ -37,9 +37,28 @@ class ExchangeKeysManager {
37
37
  * @return all available exchange keys from the delegator-delegate pair.
38
38
  */
39
39
  getDecryptionExchangeKeysFor(delegatorId, delegateId) {
40
- var _a, _b;
40
+ var _a;
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- return (_b = (_a = this.cache[delegatorId]) === null || _a === void 0 ? void 0 : _a[delegateId]) !== null && _b !== void 0 ? _b : [];
42
+ const entry = (_a = this.cache[delegatorId]) === null || _a === void 0 ? void 0 : _a[delegateId];
43
+ if (entry != undefined) {
44
+ if ('decrypted' in entry) {
45
+ return yield entry.decrypted;
46
+ }
47
+ else {
48
+ const decryptedPromise = this.decryptChunk(entry.encrypted);
49
+ this.cache[delegatorId][delegateId] = { decrypted: decryptedPromise };
50
+ return yield decryptedPromise;
51
+ }
52
+ }
53
+ else {
54
+ return [];
55
+ }
56
+ });
57
+ }
58
+ decryptChunk(encryptedKeys) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const decryptionKeys = this.keyManager.getDecryptionKeys();
61
+ return (yield this.base.tryDecryptExchangeKeys(encryptedKeys, decryptionKeys)).successfulDecryptions;
43
62
  });
44
63
  }
45
64
  /**
@@ -56,11 +75,11 @@ class ExchangeKeysManager {
56
75
  encryptedKeys[delegator] = {};
57
76
  }
58
77
  if (!encryptedKeys[delegator][dataOwner]) {
59
- encryptedKeys[delegator][dataOwner] = [];
78
+ encryptedKeys[delegator][dataOwner] = { encrypted: [] };
60
79
  }
61
80
  const keysForDelegatorDelegate = encryptedKeys[delegator][dataOwner];
62
81
  for (const encryptedEntries of Object.values(encryptedByDelegatorFp)) {
63
- keysForDelegatorDelegate.push(encryptedEntries);
82
+ keysForDelegatorDelegate.encrypted.push(encryptedEntries);
64
83
  }
65
84
  }
66
85
  for (const encryptedByDelegateId of Object.values(info.keysFromOwner)) {
@@ -69,22 +88,13 @@ class ExchangeKeysManager {
69
88
  encryptedKeys[dataOwner] = {};
70
89
  }
71
90
  if (!encryptedKeys[dataOwner][delegate]) {
72
- encryptedKeys[dataOwner][delegate] = [];
91
+ encryptedKeys[dataOwner][delegate] = { encrypted: [] };
73
92
  }
74
- encryptedKeys[dataOwner][delegate].push(encryptedEntries);
93
+ encryptedKeys[dataOwner][delegate].encrypted.push(encryptedEntries);
75
94
  }
76
95
  }
77
96
  }
78
- const decryptionKeys = this.keyManager.getDecryptionKeys();
79
- const decrypted = {};
80
- for (const [delegator, keysByDelegate] of Object.entries(encryptedKeys)) {
81
- const currDelegatorData = {};
82
- for (const [delegate, keys] of Object.entries(keysByDelegate)) {
83
- currDelegatorData[delegate] = (yield this.base.tryDecryptExchangeKeys(keys, decryptionKeys)).successfulDecryptions;
84
- }
85
- decrypted[delegator] = currDelegatorData;
86
- }
87
- this.cache = decrypted;
97
+ this.cache = encryptedKeys;
88
98
  });
89
99
  }
90
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExchangeKeysManager.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExchangeKeysManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA;;;;;;;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;QATzC,UAAK,GAAiE,E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;CACF;AApFD,kDAoFC","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\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: { [delegator: string]: { [delegate: string]: CryptoKey[] } } = {}\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\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 return this.cache[delegatorId]?.[delegateId] ?? []\n }\n\n /**\n * Reloads all exchange keys for the cache.\n */\n async reloadCache(): Promise<void> {\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]: { [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] = []\n }\n const keysForDelegatorDelegate = encryptedKeys[delegator][dataOwner]\n for (const encryptedEntries of Object.values(encryptedByDelegatorFp)) {\n keysForDelegatorDelegate.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] = []\n }\n encryptedKeys[dataOwner][delegate].push(encryptedEntries)\n }\n }\n }\n const decryptionKeys = this.keyManager.getDecryptionKeys()\n const decrypted: { [delegator: string]: { [delegate: string]: CryptoKey[] } } = {}\n for (const [delegator, keysByDelegate] of Object.entries(encryptedKeys)) {\n const currDelegatorData: { [delegate: string]: CryptoKey[] } = {}\n for (const [delegate, keys] of Object.entries(keysByDelegate)) {\n currDelegatorData[delegate] = (await this.base.tryDecryptExchangeKeys(keys, decryptionKeys)).successfulDecryptions\n }\n decrypted[delegator] = currDelegatorData\n }\n this.cache = decrypted\n }\n}\n"]}
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,CAA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AAC,aAAa,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EAAE;4BACvC,aAAa,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;yBACvD;wBACD,aAAa,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;qBACpE;iBACF;aACF;YACD,IAAI,CAAC,KAAK,GAAG,aAAa,CAAA;QAC5B,CAAC;KAAA;CACF;AA3FD,kDA2FC","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: { [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\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 entry = this.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 this.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 async reloadCache(): Promise<void> {\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 this.cache = encryptedKeys\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/api",
3
- "version": "8.0.78",
3
+ "version": "8.0.79",
4
4
  "description": "Typescript version of iCure standalone API client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,75 @@
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
+ require("isomorphic-fetch");
13
+ const util_1 = require("util");
14
+ const icc_x_api_1 = require("../../icc-x-api");
15
+ const crypto_1 = require("crypto");
16
+ function setLocalStorage(fetch) {
17
+ ;
18
+ global.localStorage = new (require('node-localstorage').LocalStorage)("/Users/trema/icure-typescript-sdk/scratch", 5 * Math.pow(1024, 3));
19
+ global.fetch = fetch;
20
+ global.Storage = '';
21
+ global.TextDecoder = util_1.TextDecoder;
22
+ global.TextEncoder = util_1.TextEncoder;
23
+ global.headers = Headers;
24
+ }
25
+ setLocalStorage(fetch);
26
+ class MyCryptoStrategies {
27
+ dataOwnerRequiresAnonymousDelegation(dataOwner) {
28
+ return false;
29
+ }
30
+ generateNewKeyForDataOwner(self, cryptoPrimitives) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return Promise.resolve(false);
33
+ });
34
+ }
35
+ recoverAndVerifySelfHierarchyKeys(keysData, cryptoPrimitives, keyPairRecoverer) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ return {
38
+ "44f19c1a-8da8-4959-90df-96a2e98112f4": {
39
+ recoveredKeys: {
40
+ "a6987fd0b8335e60a59abf0203010001": yield cryptoPrimitives.RSA.importKeyPair("pkcs8", (0, icc_x_api_1.hex2ua)("privhere"), "spki", (0, icc_x_api_1.hex2ua)("30820122300d06092a864886f70d01010105000382010f003082010a0282010100a0c7b15b203e00d233f169897ad96c3f82137c3d302e490264238fbda1f609c1152f4a1e75848e5d87133db56fa00678c4e5d9c27efb51e37d59e214b2fcfd7a5d89015a60f582d53ff8ee9c6164f003ec2f08984203008ac3d2a7f169c06cee3629611f04fc6e806a2a6ef846277c9c52c0dedd78ed11185208d0d544ee641b080b7178cb15d2a14b78e9c0e5629a2dac3a97a0a5bd13e694af68daad1ca86ee34cdeecef26db26360c6773c9c6b614b8040cdcbb306a3baac726a9928c792f6801dd65277f8febac1791fbf35eab7968bb0ed16d49308dff679a5e915e73fb827e5efa13ac04c1b2595069d7f50d4fd0e8589e7ba6987fd0b8335e60a59abf0203010001"), icc_x_api_1.ShaVersion.Sha1)
41
+ },
42
+ keyAuthenticity: {}
43
+ },
44
+ "f80f2b9f-4924-4a46-a6a4-a176f33607d8": {
45
+ recoveredKeys: {
46
+ "dd1574537845c22ac062190203010001": yield cryptoPrimitives.RSA.importKeyPair("pkcs8", (0, icc_x_api_1.hex2ua)("privhere"), "spki", (0, icc_x_api_1.hex2ua)("30820122300d06092a864886f70d01010105000382010f003082010a028201010095b3e15bf00ee73c2adea786f0783cd0ddf09e8aeded45e4a0b5982c96b8025ef6e7b31e2498073fa956dc195871e7e64f37a663900aae2ba9e6c89651b8bbb3da03e77e12424dddccf2343c2ac9e64f99f2bf1dc6fa0acfe289d0c0cb41dd0dbc6c71f8cdab722ec2a6f73a241eda7600128e64bcd0f106eca8f849fd8ec1c9c27c61d88a3c4c6940c43d7d54efc01b397e835e8ef43a2c2f216aa5ad1a281399ac513d407389d4661f68b45f7c12354547666087a2a644bdc7823e06adada1142d35cf048da03106040281b6b26a213bca037d3b63fd974fcd518938c697000a738ac2c7c6578d7ee7bb9662d35133bc8b919b37dd1574537845c22ac062190203010001"), icc_x_api_1.ShaVersion.Sha1)
47
+ },
48
+ keyAuthenticity: {}
49
+ }
50
+ };
51
+ });
52
+ }
53
+ verifyDelegatePublicKeys(delegate, publicKeys, cryptoPrimitives) {
54
+ throw "Unused";
55
+ }
56
+ }
57
+ describe('Autofix anonymity tests', () => {
58
+ it('User', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ console.log("Start init");
60
+ const api = yield icc_x_api_1.IcureApi.initialise("https://api.icure.cloud", { "username": "2de6069e-b8af-4831-aac9-75953b4780cf", password: "54d3b6ba-e969-453f-bf6c-b0a2e6f26b87" }, new MyCryptoStrategies(), crypto_1.webcrypto, fetch);
61
+ console.log("Init done");
62
+ const user = yield api.userApi.getCurrentUser();
63
+ console.log("Getting calendar items");
64
+ const calendarItems = yield api.calendarItemApi.getCalendarsByPeriodAndAgendaIdWithUser(user, 20250117000000, 20250118000000, "agenda_2de6069e-b8af-4831-aac9-75953b4780cf");
65
+ for (const ci of calendarItems) {
66
+ yield api.calendarItemApi.getDataOwnersWithAccessTo(ci);
67
+ }
68
+ // console.log(calendarItems.map((x) => x.details))
69
+ // console.log("Getting time tables")
70
+ // const timeTables: Array<TimeTable> = await api.timetableApi.getTimeTablesByPeriodAndAgendaId(20250117000000, 20250118000000, "agenda_2de6069e-b8af-4831-aac9-75953b4780cf")
71
+ // console.log("Get types")
72
+ // console.log(await api.calendarItemTypeApi.getCalendarItemTypesIncludeDeletedWithPagination())
73
+ }));
74
+ });
75
+ //# sourceMappingURL=diocancaro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diocancaro.js","sourceRoot":"","sources":["../../../test/icc-x-api/diocancaro.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,+BAA8C;AAC9C,+CAA0G;AAI1G,mCAAiC;AAIjC,SAAS,eAAe,CAAC,KAAoE;IAC3F,CAAC;IAAC,MAAc,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,CAAC,2CAA2C,EAAE,CAAC,GAAG,SAAA,IAAI,EAAI,CAAC,CAAA,CAAC,CAC1I;IAAC,MAAc,CAAC,KAAK,GAAG,KAAK,CAC7B;IAAC,MAAc,CAAC,OAAO,GAAG,EAAE,CAC5B;IAAC,MAAc,CAAC,WAAW,GAAG,kBAAW,CACzC;IAAC,MAAc,CAAC,WAAW,GAAG,kBAAW,CACzC;IAAC,MAAc,CAAC,OAAO,GAAG,OAAO,CAAA;AACpC,CAAC;AACD,eAAe,CAAC,KAAK,CAAC,CAAA;AAEtB,MAAM,kBAAkB;IACtB,oCAAoC,CAAC,SAAkC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IAEK,0BAA0B,CAAC,IAAuB,EAAE,gBAAkC;;YAC1F,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;KAAA;IAEK,iCAAiC,CAAC,QAIrC,EAAE,gBAAkC,EAAE,gBAAkC;;YAGzE,OAAO;gBACL,sCAAsC,EAAE;oBACtC,aAAa,EAAE;wBACb,kCAAkC,EAAE,MAAM,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAC1E,OAAO,EACP,IAAA,kBAAM,EAAC,UAAU,CAAC,EAClB,MAAM,EACN,IAAA,kBAAM,EAAC,8kBAA8kB,CAAC,EACtlB,sBAAU,CAAC,IAAI,CAChB;qBACF;oBACD,eAAe,EAAE,EAAE;iBACpB;gBACD,sCA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A;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport {TextDecoder, TextEncoder} from \"util\";\nimport {CryptoPrimitives, CryptoStrategies, hex2ua, IcureApi, KeyPair, ShaVersion} from \"../../icc-x-api\";\nimport {CryptoActorStubWithType} from \"../../icc-api/model/CryptoActorStub\";\nimport {DataOwnerWithType} from \"../../icc-api/model/DataOwnerWithType\";\nimport {KeyPairRecoverer} from \"../../icc-x-api/crypto/KeyPairRecoverer\";\nimport {webcrypto} from \"crypto\";\nimport {CalendarItem} from \"../../icc-api/model/CalendarItem\";\nimport {TimeTable} from \"../../icc-api/model/TimeTable\";\n\nfunction setLocalStorage(fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>) {\n ;(global as any).localStorage = new (require('node-localstorage').LocalStorage)(\"/Users/trema/icure-typescript-sdk/scratch\", 5 * 1024 ** 3)\n ;(global as any).fetch = fetch\n ;(global as any).Storage = ''\n ;(global as any).TextDecoder = TextDecoder\n ;(global as any).TextEncoder = TextEncoder\n ;(global as any).headers = Headers\n}\nsetLocalStorage(fetch)\n\nclass MyCryptoStrategies implements CryptoStrategies {\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return false;\n }\n\n async generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean> {\n return Promise.resolve(false);\n }\n\n async recoverAndVerifySelfHierarchyKeys(keysData: {\n dataOwner: DataOwnerWithType;\n unknownKeys: string[];\n unavailableKeys: string[]\n }[], cryptoPrimitives: CryptoPrimitives, keyPairRecoverer: KeyPairRecoverer): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n return {\n \"44f19c1a-8da8-4959-90df-96a2e98112f4\": {\n recoveredKeys: {\n \"a6987fd0b8335e60a59abf0203010001\": await cryptoPrimitives.RSA.importKeyPair(\n \"pkcs8\",\n hex2ua(\"privhere\"),\n \"spki\",\n hex2ua(\"30820122300d06092a864886f70d01010105000382010f003082010a0282010100a0c7b15b203e00d233f169897ad96c3f82137c3d302e490264238fbda1f609c1152f4a1e75848e5d87133db56fa00678c4e5d9c27efb51e37d59e214b2fcfd7a5d89015a60f582d53ff8ee9c6164f003ec2f08984203008ac3d2a7f169c06cee3629611f04fc6e806a2a6ef846277c9c52c0dedd78ed11185208d0d544ee641b080b7178cb15d2a14b78e9c0e5629a2dac3a97a0a5bd13e694af68daad1ca86ee34cdeecef26db26360c6773c9c6b614b8040cdcbb306a3baac726a9928c792f6801dd65277f8febac1791fbf35eab7968bb0ed16d49308dff679a5e915e73fb827e5efa13ac04c1b2595069d7f50d4fd0e8589e7ba6987fd0b8335e60a59abf0203010001\"),\n ShaVersion.Sha1\n )\n },\n keyAuthenticity: {}\n },\n \"f80f2b9f-4924-4a46-a6a4-a176f33607d8\": {\n recoveredKeys: {\n \"dd1574537845c22ac062190203010001\": await cryptoPrimitives.RSA.importKeyPair(\n \"pkcs8\",\n hex2ua(\"privhere\"),\n \"spki\",\n hex2ua(\"30820122300d06092a864886f70d01010105000382010f003082010a028201010095b3e15bf00ee73c2adea786f0783cd0ddf09e8aeded45e4a0b5982c96b8025ef6e7b31e2498073fa956dc195871e7e64f37a663900aae2ba9e6c89651b8bbb3da03e77e12424dddccf2343c2ac9e64f99f2bf1dc6fa0acfe289d0c0cb41dd0dbc6c71f8cdab722ec2a6f73a241eda7600128e64bcd0f106eca8f849fd8ec1c9c27c61d88a3c4c6940c43d7d54efc01b397e835e8ef43a2c2f216aa5ad1a281399ac513d407389d4661f68b45f7c12354547666087a2a644bdc7823e06adada1142d35cf048da03106040281b6b26a213bca037d3b63fd974fcd518938c697000a738ac2c7c6578d7ee7bb9662d35133bc8b919b37dd1574537845c22ac062190203010001\"),\n ShaVersion.Sha1\n )\n },\n keyAuthenticity: {}\n }\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n throw \"Unused\";\n }\n\n}\n\ndescribe('Autofix anonymity tests', () => {\n it('User', async () => {\n console.log(\"Start init\")\n const api = await IcureApi.initialise(\n \"https://api.icure.cloud\",\n { \"username\": \"2de6069e-b8af-4831-aac9-75953b4780cf\", password: \"54d3b6ba-e969-453f-bf6c-b0a2e6f26b87\"},\n new MyCryptoStrategies(),\n webcrypto as any,\n fetch,\n )\n console.log(\"Init done\")\n const user = await api.userApi.getCurrentUser()\n console.log(\"Getting calendar items\")\n const calendarItems: Array<CalendarItem> = await api.calendarItemApi.getCalendarsByPeriodAndAgendaIdWithUser(user, 20250117000000, 20250118000000, \"agenda_2de6069e-b8af-4831-aac9-75953b4780cf\")\n for (const ci of calendarItems) {\n await api.calendarItemApi.getDataOwnersWithAccessTo(ci)\n }\n // console.log(calendarItems.map((x) => x.details))\n // console.log(\"Getting time tables\")\n // const timeTables: Array<TimeTable> = await api.timetableApi.getTimeTablesByPeriodAndAgendaId(20250117000000, 20250118000000, \"agenda_2de6069e-b8af-4831-aac9-75953b4780cf\")\n // console.log(\"Get types\")\n // console.log(await api.calendarItemTypeApi.getCalendarItemTypesIncludeDeletedWithPagination())\n })\n})"]}