@icure/api 8.0.25 → 8.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-x-api/crypto/CryptoPrimitives.d.ts +1 -1
- package/icc-x-api/crypto/CryptoPrimitives.js +3 -3
- package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -1
- package/icc-x-api/index.d.ts +3 -2
- package/icc-x-api/index.js +1 -1
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js +1 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.js +1 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -1
- package/test/icc-x-api/crypto/full-crypto-test.js +1 -1
- package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js +1 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -1
- package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js +2 -2
- package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js.map +1 -1
- package/test/icc-x-api/crypto/signature-keys-manager-test.js +1 -1
- package/test/icc-x-api/crypto/signature-keys-manager-test.js.map +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js.map +1 -1
- package/test/icc-x-api/test-legacy-data-support.js +1 -1
- package/test/icc-x-api/test-legacy-data-support.js.map +1 -1
- package/test/utils/FakeDataOwnerApi.js +1 -1
- package/test/utils/FakeDataOwnerApi.js.map +1 -1
- package/test/utils/FakeGenericApi.js +1 -1
- package/test/utils/FakeGenericApi.js.map +1 -1
- package/test/utils/test_utils.js +5 -5
- package/test/utils/test_utils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-delegations-metadata-decryptor-test.js","sourceRoot":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,EAAE,0BAA0B,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;gBACvI,MAAM,wBAAwB,CAAC,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAA;gBACvG,MAAM,wBAAwB,CAAC,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;gBAC9I,MAAM,wBAAwB,CAAC,CAAC,qBAAqB,EAAE,qBAAqB,EAAE,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;gBAC5I,MAAM,wBAAwB,CAAC,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;YAC7F,CAAC;SAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { describe } from 'mocha'\nimport { CryptoPrimitives, CryptoPrimitivesImpl } from '../../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\nimport { FakeEncryptionKeysManager } from '../../utils/FakeEncryptionKeysManager'\nimport { SecureDelegationsSecurityMetadataDecryptor } from '../../../icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor'\nimport { SecureDelegationsEncryption } from '../../../icc-x-api/crypto/SecureDelegationsEncryption'\nimport { FakeDecryptionExchangeDataManager } from '../../utils/FakeExchangeDataManager'\nimport { EncryptedEntityWithType, EntityWithDelegationTypeName } from '../../../icc-x-api/utils/EntityWithDelegationTypeName'\nimport { ExchangeData } from '../../../icc-api/model/internal/ExchangeData'\nimport { expect } from 'chai'\nimport { IcureStub } from '../../../icc-api/model/IcureStub'\nimport { SecureDelegation } from '../../../icc-api/model/SecureDelegation'\nimport { ShaVersion, ua2hex } from '../../../icc-x-api'\nimport { SecurityMetadata } from '../../../icc-api/model/SecurityMetadata'\nimport { asyncGeneratorToArray } from '../../../icc-x-api/utils/collection-utils'\nimport { FakeExchangeDataMapManager } from '../../utils/FakeExchangeDataMapManager'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\n\ndescribe('Secure delegations security metadata decryptor', async function () {\n const primitives = new CryptoPrimitivesImpl(webcrypto as any)\n const expectedType: EntityWithDelegationTypeName = EntityWithDelegationTypeName.AccessLog\n const expectedSfks = [primitives.randomUuid(), primitives.randomUuid()]\n let encryptionKeysManager: FakeEncryptionKeysManager\n let exchangeData: FakeDecryptionExchangeDataManager\n let exchangeDataMap: FakeExchangeDataMapManager\n let decryptor: SecureDelegationsSecurityMetadataDecryptor\n let secureDelegationsEncryption: SecureDelegationsEncryption\n\n class SecureDelegationWithEncryptedExchangeId extends SecureDelegation {\n constructor(json: JSON | any) {\n super(json)\n Object.assign(this as SecureDelegationWithEncryptedExchangeId, json)\n }\n\n encryptedExchangeDataId!: { [fp: string]: string }\n }\n\n async function cacheExchangeDataMaps(secureDelegations: { [hash: string]: SecureDelegationWithEncryptedExchangeId }) {\n await exchangeDataMap.createExchangeDataMaps(\n Object.entries(secureDelegations).reduce((p, [hash, secDel]) => {\n return {\n ...p,\n [hash]: secDel.encryptedExchangeDataId,\n }\n }, {} as { [hash: string]: { [fp: string]: string } })\n )\n }\n\n async function initialiseComponents() {\n encryptionKeysManager = await FakeEncryptionKeysManager.create(primitives, [], [await primitives.RSA.generateKeyPair(ShaVersion.Sha256)])\n exchangeData = new FakeDecryptionExchangeDataManager(expectedType, expectedSfks, new CryptoPrimitivesImpl(webcrypto as any))\n exchangeDataMap = new FakeExchangeDataMapManager()\n secureDelegationsEncryption = new SecureDelegationsEncryption(encryptionKeysManager, primitives)\n decryptor = new SecureDelegationsSecurityMetadataDecryptor(exchangeData, exchangeDataMap, secureDelegationsEncryption, undefined as any) // data owner api not used in these tests\n }\n\n async function randomHash(): Promise<string> {\n return ua2hex(await primitives.sha256(primitives.randomBytes(4)))\n }\n\n async function createExchangeDataAndSecureDelegationEncryptedData(\n exchangeDataDelegator: string,\n exchangeDataDelegate: string\n ): Promise<{\n exchangeData: ExchangeData\n exchangeKey: CryptoKey\n secureDelegationEncryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n expectedDecryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n }> {\n const exchangeKey = await primitives.AES.generateCryptoKey(false)\n const exchangeData = new ExchangeData({\n id: primitives.randomUuid(),\n delegator: exchangeDataDelegator,\n delegate: exchangeDataDelegate,\n exchangeKey: { ignored: 'in this test' },\n accessControlSecret: { ignored: 'in this test' },\n sharedSignatureKey: { ignored: 'in this test' },\n delegatorSignature: { ignored: 'in this test' },\n sharedSignature: 'ignored in this test',\n })\n const expectedDecryptedData = {\n secretIds: [primitives.randomUuid(), primitives.randomUuid()],\n encryptionKeys: [await primitives.AES.generateCryptoKey(true), await primitives.AES.generateCryptoKey(true)],\n owningEntityIds: [primitives.randomUuid(), primitives.randomUuid()],\n }\n const secureDelegationEncryptedData = {\n secretIds: await Promise.all(expectedDecryptedData.secretIds.map((x) => secureDelegationsEncryption.encryptSecretId(x, exchangeKey))),\n encryptionKeys: await Promise.all(\n expectedDecryptedData.encryptionKeys.map((x) => secureDelegationsEncryption.encryptEncryptionKey(x, exchangeKey))\n ),\n owningEntityIds: await Promise.all(\n expectedDecryptedData.owningEntityIds.map((x) => secureDelegationsEncryption.encryptOwningEntityId(x, exchangeKey))\n ),\n }\n return { exchangeKey, exchangeData, expectedDecryptedData, secureDelegationEncryptedData }\n }\n\n function entityWithSecurityMetadata(securityMetadata: SecurityMetadata): EncryptedEntityWithType {\n return {\n entity: new IcureStub({\n secretForeignKeys: expectedSfks,\n securityMetadata,\n }),\n type: expectedType,\n }\n }\n\n function toSortedJson(data: { decrypted: string; dataOwnersWithAccess: string[] }): string {\n return JSON.stringify({\n decrypted: data.decrypted,\n dataOwnersWithAccess: [...data.dataOwnersWithAccess].sort(),\n })\n }\n\n async function verifyCanDecryptEntityData(\n entity: EncryptedEntityWithType,\n dataOwnerHierarchySubset: string[],\n expected: {\n exchangeData: ExchangeData\n expectedDecryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n }[]\n ) {\n const actualSecretIds = (await asyncGeneratorToArray(decryptor.decryptSecretIdsOf(entity, dataOwnerHierarchySubset))).map(toSortedJson)\n const actualOwningEntityIds = (await asyncGeneratorToArray(decryptor.decryptOwningEntityIdsOf(entity, dataOwnerHierarchySubset))).map(\n toSortedJson\n )\n const actualEncryptionKeys = (await asyncGeneratorToArray(decryptor.decryptEncryptionKeysOf(entity, dataOwnerHierarchySubset))).map(toSortedJson)\n const expectedSecretIds: string[] = []\n const expectedOwningEntityIds: string[] = []\n const expectedEncryptionKeys: string[] = []\n for (const data of expected) {\n data.expectedDecryptedData.secretIds.forEach((x) =>\n expectedSecretIds.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n data.expectedDecryptedData.owningEntityIds.forEach((x) =>\n expectedOwningEntityIds.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n data.expectedDecryptedData.encryptionKeys.forEach((x) =>\n expectedEncryptionKeys.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n }\n expect(actualSecretIds).to.have.members(expectedSecretIds)\n expect(actualOwningEntityIds).to.have.members(expectedOwningEntityIds)\n expect(actualEncryptionKeys).to.have.members(expectedEncryptionKeys)\n }\n\n it('should be able to decrypt data from a secure delegation accessible by hash if the hash is cached', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: undefined,\n delegate: undefined,\n exchangeDataId: undefined,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: undefined,\n delegate: undefined,\n exchangeDataId: undefined,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const hash1 = await randomHash()\n const hash2 = await randomHash()\n const hash3 = await randomHash()\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [hash1]: delegation1, [hash2]: delegation2 },\n keysEquivalences: { [hash3]: hash2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [hash1] })\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [hash3] })\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from a secure delegation with clear text id where the delegator or delegate are in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from a secure delegation with encrypted id if the keys to decrypt the id are available and the delegator or delegate is in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const encryptionKeys = Object.fromEntries(Object.entries(encryptionKeysManager.getDecryptionKeys()).map(([fp, pair]) => [fp, pair.publicKey]))\n const delegation1 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData1.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData2.secureDelegationEncryptedData,\n delegate: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData2.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegations = { [await randomHash()]: delegation1, [await randomHash()]: delegation2 }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegations,\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegations)\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from secure delegations accessible by encrypted or cleartext id', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const createdData3 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData4 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const encryptionKeys = Object.fromEntries(Object.entries(encryptionKeysManager.getDecryptionKeys()).map(([fp, pair]) => [fp, pair.publicKey]))\n const delegation1 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation3 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData3.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData3.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const delegation4 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData4.secureDelegationEncryptedData,\n delegate: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData4.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegations = {\n [await randomHash()]: delegation1,\n [await randomHash()]: delegation2,\n [await randomHash()]: delegation3,\n [await randomHash()]: delegation4,\n }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegations,\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n exchangeData.cacheFakeData(createdData3.exchangeData, { exchangeKey: createdData3.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData4.exchangeData, { exchangeKey: createdData4.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegations)\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2, createdData3, createdData4])\n })\n\n // Note: mixed scenario where part of secure delegation is accessible by hash and part by id (clear-text or encrypted) is not realistic and not tested\n\n it('should ignore delegations accessible by id where the neither the delegator nor delegate are in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), primitives.randomUuid())\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: primitives.randomUuid(),\n delegate: primitives.randomUuid(),\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: primitives.randomUuid(),\n delegate: primitives.randomUuid(),\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n await verifyCanDecryptEntityData(entity, [primitives.randomUuid()], [])\n })\n\n it('should ignore secure delegation with encrypted id if the keys to decrypt the id are not available', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newKeyFp = ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')).slice(-32)\n const delegation = new SecureDelegationWithEncryptedExchangeId({\n ...createdData.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData.exchangeData.id!, {\n [newKeyFp]: newKey.publicKey,\n }),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegation = { [await randomHash()]: delegation }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegation,\n })\n )\n exchangeData.cacheFakeData(createdData.exchangeData, { exchangeKey: createdData.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegation)\n await verifyCanDecryptEntityData(entity, [self], [])\n })\n\n it('should ignore secure delegations corresponding to exchange data which could not be decrypted', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] })\n exchangeData.cacheFakeData(createdData2.exchangeData, undefined)\n await verifyCanDecryptEntityData(entity, [self], [createdData1])\n })\n\n it('should give an error if dataOwnersHierarchySubset is empty', async function () {\n await initialiseComponents()\n const entity = {\n entity: new IcureStub({ secretForeignKeys: expectedSfks }),\n type: expectedType,\n }\n let failed = 0\n try {\n decryptor.decryptEncryptionKeysOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n decryptor.decryptSecretIdsOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n decryptor.decryptOwningEntityIdsOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n await decryptor.getEntityAccessLevel(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n expect(failed).to.equal(4)\n })\n\n it('should return the best access level with directly accessible secure delegations', async function () {\n await initialiseComponents()\n const dataOwnerA = primitives.randomUuid()\n const dataOwnerB = primitives.randomUuid()\n const secureDelegationWriteA = new SecureDelegation({ delegator: dataOwnerA, permissions: AccessLevel.WRITE })\n const secureDelegationReadA = new SecureDelegation({ delegate: dataOwnerA, permissions: AccessLevel.READ })\n const secureDelegationWriteB = new SecureDelegation({ delegate: dataOwnerB, permissions: AccessLevel.WRITE })\n const secureDelegationReadB = new SecureDelegation({ delegator: dataOwnerB, permissions: AccessLevel.READ })\n const secureDelegationWriteOther = new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.WRITE })\n const secureDelegationReadOther = new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.READ })\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA]\n )\n ).to.equal(AccessLevel.READ)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA]\n )\n ).to.equal(undefined)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationReadB,\n [await randomHash()]: secureDelegationWriteOther,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.READ)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationWriteA,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n })\n\n it('should return the best access level with secure delegations accessible through hash', async function () {\n const hashA = await randomHash()\n const hashB = await randomHash()\n const secureDelegationWriteA: [string, SecureDelegation] = [hashA, new SecureDelegation({ permissions: AccessLevel.WRITE })]\n const secureDelegationReadA: [string, SecureDelegation] = [hashA, new SecureDelegation({ permissions: AccessLevel.READ })]\n const secureDelegationWriteB: [string, SecureDelegation] = [hashB, new SecureDelegation({ permissions: AccessLevel.WRITE })]\n const secureDelegationReadB: [string, SecureDelegation] = [hashB, new SecureDelegation({ permissions: AccessLevel.READ })]\n const secureDelegationWriteOther: [string, SecureDelegation] = [\n await randomHash(),\n new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.WRITE }),\n ]\n const secureDelegationReadOther: [string, SecureDelegation] = [\n await randomHash(),\n new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.READ }),\n ]\n\n async function testWithEntriesAndHashes(entries: [string, SecureDelegation][], hashes: string[], expectedLevel: AccessLevel | undefined) {\n await initialiseComponents()\n for (const hash of hashes) {\n exchangeData.cacheFakeData({} as any, { exchangeKey: {} as any, hashes: [hash] })\n }\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: Object.fromEntries(entries),\n }),\n [primitives.randomUuid()]\n )\n ).to.equal(expectedLevel)\n }\n\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashA], AccessLevel.READ)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashB], AccessLevel.WRITE)\n await testWithEntriesAndHashes([secureDelegationWriteB, secureDelegationReadOther], [hashA], undefined)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashA, hashB], AccessLevel.WRITE)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationReadB, secureDelegationWriteOther], [hashA, hashB], AccessLevel.READ)\n await testWithEntriesAndHashes([secureDelegationWriteA], [hashA, hashB], AccessLevel.WRITE)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"secure-delegations-metadata-decryptor-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAgC;AAChC,iFAAkG;AAClG,mCAAkC;AAClC,qFAAiF;AACjF,qIAAiI;AACjI,uGAAmG;AACnG,iFAAuF;AACvF,wGAA6H;AAC7H,+EAA2E;AAC3E,+BAA6B;AAC7B,gEAA4D;AAC5D,8EAA0E;AAC1E,kDAAuD;AACvD,8EAA0E;AAC1E,gFAAiF;AACjF,uFAAmF;AACnF,IAAO,WAAW,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAErD,IAAA,gBAAQ,EAAC,gDAAgD,EAAE;;QACzD,MAAM,UAAU,GAAG,IAAI,sCAAmB,CAAC,kBAAgB,CAAC,CAAA;QAC5D,MAAM,YAAY,GAAiC,2DAA4B,CAAC,SAAS,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AAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;YAC7F,CAAC;SAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { describe } from 'mocha'\nimport { CryptoPrimitives, WebCryptoPrimitives } from '../../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\nimport { FakeEncryptionKeysManager } from '../../utils/FakeEncryptionKeysManager'\nimport { SecureDelegationsSecurityMetadataDecryptor } from '../../../icc-x-api/crypto/SecureDelegationsSecurityMetadataDecryptor'\nimport { SecureDelegationsEncryption } from '../../../icc-x-api/crypto/SecureDelegationsEncryption'\nimport { FakeDecryptionExchangeDataManager } from '../../utils/FakeExchangeDataManager'\nimport { EncryptedEntityWithType, EntityWithDelegationTypeName } from '../../../icc-x-api/utils/EntityWithDelegationTypeName'\nimport { ExchangeData } from '../../../icc-api/model/internal/ExchangeData'\nimport { expect } from 'chai'\nimport { IcureStub } from '../../../icc-api/model/IcureStub'\nimport { SecureDelegation } from '../../../icc-api/model/SecureDelegation'\nimport { ShaVersion, ua2hex } from '../../../icc-x-api'\nimport { SecurityMetadata } from '../../../icc-api/model/SecurityMetadata'\nimport { asyncGeneratorToArray } from '../../../icc-x-api/utils/collection-utils'\nimport { FakeExchangeDataMapManager } from '../../utils/FakeExchangeDataMapManager'\nimport AccessLevel = SecureDelegation.AccessLevelEnum\n\ndescribe('Secure delegations security metadata decryptor', async function () {\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const expectedType: EntityWithDelegationTypeName = EntityWithDelegationTypeName.AccessLog\n const expectedSfks = [primitives.randomUuid(), primitives.randomUuid()]\n let encryptionKeysManager: FakeEncryptionKeysManager\n let exchangeData: FakeDecryptionExchangeDataManager\n let exchangeDataMap: FakeExchangeDataMapManager\n let decryptor: SecureDelegationsSecurityMetadataDecryptor\n let secureDelegationsEncryption: SecureDelegationsEncryption\n\n class SecureDelegationWithEncryptedExchangeId extends SecureDelegation {\n constructor(json: JSON | any) {\n super(json)\n Object.assign(this as SecureDelegationWithEncryptedExchangeId, json)\n }\n\n encryptedExchangeDataId!: { [fp: string]: string }\n }\n\n async function cacheExchangeDataMaps(secureDelegations: { [hash: string]: SecureDelegationWithEncryptedExchangeId }) {\n await exchangeDataMap.createExchangeDataMaps(\n Object.entries(secureDelegations).reduce((p, [hash, secDel]) => {\n return {\n ...p,\n [hash]: secDel.encryptedExchangeDataId,\n }\n }, {} as { [hash: string]: { [fp: string]: string } })\n )\n }\n\n async function initialiseComponents() {\n encryptionKeysManager = await FakeEncryptionKeysManager.create(primitives, [], [await primitives.RSA.generateKeyPair(ShaVersion.Sha256)])\n exchangeData = new FakeDecryptionExchangeDataManager(expectedType, expectedSfks, new WebCryptoPrimitives(webcrypto as any))\n exchangeDataMap = new FakeExchangeDataMapManager()\n secureDelegationsEncryption = new SecureDelegationsEncryption(encryptionKeysManager, primitives)\n decryptor = new SecureDelegationsSecurityMetadataDecryptor(exchangeData, exchangeDataMap, secureDelegationsEncryption, undefined as any) // data owner api not used in these tests\n }\n\n async function randomHash(): Promise<string> {\n return ua2hex(await primitives.sha256(primitives.randomBytes(4)))\n }\n\n async function createExchangeDataAndSecureDelegationEncryptedData(\n exchangeDataDelegator: string,\n exchangeDataDelegate: string\n ): Promise<{\n exchangeData: ExchangeData\n exchangeKey: CryptoKey\n secureDelegationEncryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n expectedDecryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n }> {\n const exchangeKey = await primitives.AES.generateCryptoKey(false)\n const exchangeData = new ExchangeData({\n id: primitives.randomUuid(),\n delegator: exchangeDataDelegator,\n delegate: exchangeDataDelegate,\n exchangeKey: { ignored: 'in this test' },\n accessControlSecret: { ignored: 'in this test' },\n sharedSignatureKey: { ignored: 'in this test' },\n delegatorSignature: { ignored: 'in this test' },\n sharedSignature: 'ignored in this test',\n })\n const expectedDecryptedData = {\n secretIds: [primitives.randomUuid(), primitives.randomUuid()],\n encryptionKeys: [await primitives.AES.generateCryptoKey(true), await primitives.AES.generateCryptoKey(true)],\n owningEntityIds: [primitives.randomUuid(), primitives.randomUuid()],\n }\n const secureDelegationEncryptedData = {\n secretIds: await Promise.all(expectedDecryptedData.secretIds.map((x) => secureDelegationsEncryption.encryptSecretId(x, exchangeKey))),\n encryptionKeys: await Promise.all(\n expectedDecryptedData.encryptionKeys.map((x) => secureDelegationsEncryption.encryptEncryptionKey(x, exchangeKey))\n ),\n owningEntityIds: await Promise.all(\n expectedDecryptedData.owningEntityIds.map((x) => secureDelegationsEncryption.encryptOwningEntityId(x, exchangeKey))\n ),\n }\n return { exchangeKey, exchangeData, expectedDecryptedData, secureDelegationEncryptedData }\n }\n\n function entityWithSecurityMetadata(securityMetadata: SecurityMetadata): EncryptedEntityWithType {\n return {\n entity: new IcureStub({\n secretForeignKeys: expectedSfks,\n securityMetadata,\n }),\n type: expectedType,\n }\n }\n\n function toSortedJson(data: { decrypted: string; dataOwnersWithAccess: string[] }): string {\n return JSON.stringify({\n decrypted: data.decrypted,\n dataOwnersWithAccess: [...data.dataOwnersWithAccess].sort(),\n })\n }\n\n async function verifyCanDecryptEntityData(\n entity: EncryptedEntityWithType,\n dataOwnerHierarchySubset: string[],\n expected: {\n exchangeData: ExchangeData\n expectedDecryptedData: {\n secretIds: string[]\n encryptionKeys: string[]\n owningEntityIds: string[]\n }\n }[]\n ) {\n const actualSecretIds = (await asyncGeneratorToArray(decryptor.decryptSecretIdsOf(entity, dataOwnerHierarchySubset))).map(toSortedJson)\n const actualOwningEntityIds = (await asyncGeneratorToArray(decryptor.decryptOwningEntityIdsOf(entity, dataOwnerHierarchySubset))).map(\n toSortedJson\n )\n const actualEncryptionKeys = (await asyncGeneratorToArray(decryptor.decryptEncryptionKeysOf(entity, dataOwnerHierarchySubset))).map(toSortedJson)\n const expectedSecretIds: string[] = []\n const expectedOwningEntityIds: string[] = []\n const expectedEncryptionKeys: string[] = []\n for (const data of expected) {\n data.expectedDecryptedData.secretIds.forEach((x) =>\n expectedSecretIds.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n data.expectedDecryptedData.owningEntityIds.forEach((x) =>\n expectedOwningEntityIds.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n data.expectedDecryptedData.encryptionKeys.forEach((x) =>\n expectedEncryptionKeys.push(toSortedJson({ decrypted: x, dataOwnersWithAccess: [data.exchangeData.delegate, data.exchangeData.delegator] }))\n )\n }\n expect(actualSecretIds).to.have.members(expectedSecretIds)\n expect(actualOwningEntityIds).to.have.members(expectedOwningEntityIds)\n expect(actualEncryptionKeys).to.have.members(expectedEncryptionKeys)\n }\n\n it('should be able to decrypt data from a secure delegation accessible by hash if the hash is cached', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: undefined,\n delegate: undefined,\n exchangeDataId: undefined,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: undefined,\n delegate: undefined,\n exchangeDataId: undefined,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const hash1 = await randomHash()\n const hash2 = await randomHash()\n const hash3 = await randomHash()\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [hash1]: delegation1, [hash2]: delegation2 },\n keysEquivalences: { [hash3]: hash2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [hash1] })\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [hash3] })\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from a secure delegation with clear text id where the delegator or delegate are in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from a secure delegation with encrypted id if the keys to decrypt the id are available and the delegator or delegate is in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const encryptionKeys = Object.fromEntries(Object.entries(encryptionKeysManager.getDecryptionKeys()).map(([fp, pair]) => [fp, pair.publicKey]))\n const delegation1 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData1.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData2.secureDelegationEncryptedData,\n delegate: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData2.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegations = { [await randomHash()]: delegation1, [await randomHash()]: delegation2 }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegations,\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegations)\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2])\n })\n\n it('should be able to decrypt data from secure delegations accessible by encrypted or cleartext id', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const createdData3 = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const createdData4 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), self)\n const encryptionKeys = Object.fromEntries(Object.entries(encryptionKeysManager.getDecryptionKeys()).map(([fp, pair]) => [fp, pair.publicKey]))\n const delegation1 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation3 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData3.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData3.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const delegation4 = new SecureDelegationWithEncryptedExchangeId({\n ...createdData4.secureDelegationEncryptedData,\n delegate: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData4.exchangeData.id!, encryptionKeys),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegations = {\n [await randomHash()]: delegation1,\n [await randomHash()]: delegation2,\n [await randomHash()]: delegation3,\n [await randomHash()]: delegation4,\n }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegations,\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData2.exchangeData, { exchangeKey: createdData2.exchangeKey, hashes: [] })\n exchangeData.cacheFakeData(createdData3.exchangeData, { exchangeKey: createdData3.exchangeKey, hashes: [] }, true)\n exchangeData.cacheFakeData(createdData4.exchangeData, { exchangeKey: createdData4.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegations)\n await verifyCanDecryptEntityData(entity, [self], [createdData1, createdData2, createdData3, createdData4])\n })\n\n // Note: mixed scenario where part of secure delegation is accessible by hash and part by id (clear-text or encrypted) is not realistic and not tested\n\n it('should ignore delegations accessible by id where the neither the delegator nor delegate are in dataOwnersHierarchySubset', async function () {\n await initialiseComponents()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), primitives.randomUuid())\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(primitives.randomUuid(), primitives.randomUuid())\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: primitives.randomUuid(),\n delegate: primitives.randomUuid(),\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: primitives.randomUuid(),\n delegate: primitives.randomUuid(),\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n await verifyCanDecryptEntityData(entity, [primitives.randomUuid()], [])\n })\n\n it('should ignore secure delegation with encrypted id if the keys to decrypt the id are not available', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const createdData = await createExchangeDataAndSecureDelegationEncryptedData(self, primitives.randomUuid())\n const newKey = await primitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const newKeyFp = ua2hex(await primitives.RSA.exportKey(newKey.publicKey, 'spki')).slice(-32)\n const delegation = new SecureDelegationWithEncryptedExchangeId({\n ...createdData.secureDelegationEncryptedData,\n delegator: self,\n encryptedExchangeDataId: await secureDelegationsEncryption.encryptExchangeDataId(createdData.exchangeData.id!, {\n [newKeyFp]: newKey.publicKey,\n }),\n permissions: AccessLevel.WRITE,\n })\n const secureDelegation = { [await randomHash()]: delegation }\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: secureDelegation,\n })\n )\n exchangeData.cacheFakeData(createdData.exchangeData, { exchangeKey: createdData.exchangeKey, hashes: [] })\n await cacheExchangeDataMaps(secureDelegation)\n await verifyCanDecryptEntityData(entity, [self], [])\n })\n\n it('should ignore secure delegations corresponding to exchange data which could not be decrypted', async function () {\n await initialiseComponents()\n const self = primitives.randomUuid()\n const other1 = primitives.randomUuid()\n const other2 = primitives.randomUuid()\n const createdData1 = await createExchangeDataAndSecureDelegationEncryptedData(self, other1)\n const createdData2 = await createExchangeDataAndSecureDelegationEncryptedData(other2, self)\n const delegation1 = new SecureDelegation({\n ...createdData1.secureDelegationEncryptedData,\n delegator: self,\n delegate: other1,\n exchangeDataId: createdData1.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const delegation2 = new SecureDelegation({\n ...createdData2.secureDelegationEncryptedData,\n delegator: other2,\n delegate: self,\n exchangeDataId: createdData2.exchangeData.id,\n encryptedExchangeDataId: undefined,\n permissions: AccessLevel.WRITE,\n })\n const entity = entityWithSecurityMetadata(\n new SecurityMetadata({\n secureDelegations: { [await randomHash()]: delegation1, [await randomHash()]: delegation2 },\n })\n )\n exchangeData.cacheFakeData(createdData1.exchangeData, { exchangeKey: createdData1.exchangeKey, hashes: [] })\n exchangeData.cacheFakeData(createdData2.exchangeData, undefined)\n await verifyCanDecryptEntityData(entity, [self], [createdData1])\n })\n\n it('should give an error if dataOwnersHierarchySubset is empty', async function () {\n await initialiseComponents()\n const entity = {\n entity: new IcureStub({ secretForeignKeys: expectedSfks }),\n type: expectedType,\n }\n let failed = 0\n try {\n decryptor.decryptEncryptionKeysOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n decryptor.decryptSecretIdsOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n decryptor.decryptOwningEntityIdsOf(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n try {\n await decryptor.getEntityAccessLevel(entity, [])\n } catch (e) {\n console.log(e)\n failed++\n }\n expect(failed).to.equal(4)\n })\n\n it('should return the best access level with directly accessible secure delegations', async function () {\n await initialiseComponents()\n const dataOwnerA = primitives.randomUuid()\n const dataOwnerB = primitives.randomUuid()\n const secureDelegationWriteA = new SecureDelegation({ delegator: dataOwnerA, permissions: AccessLevel.WRITE })\n const secureDelegationReadA = new SecureDelegation({ delegate: dataOwnerA, permissions: AccessLevel.READ })\n const secureDelegationWriteB = new SecureDelegation({ delegate: dataOwnerB, permissions: AccessLevel.WRITE })\n const secureDelegationReadB = new SecureDelegation({ delegator: dataOwnerB, permissions: AccessLevel.READ })\n const secureDelegationWriteOther = new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.WRITE })\n const secureDelegationReadOther = new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.READ })\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA]\n )\n ).to.equal(AccessLevel.READ)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA]\n )\n ).to.equal(undefined)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationWriteOther,\n [await randomHash()]: secureDelegationWriteB,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationReadA,\n [await randomHash()]: secureDelegationReadB,\n [await randomHash()]: secureDelegationWriteOther,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.READ)\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: {\n [await randomHash()]: secureDelegationWriteA,\n },\n }),\n [dataOwnerA, dataOwnerB]\n )\n ).to.equal(AccessLevel.WRITE)\n })\n\n it('should return the best access level with secure delegations accessible through hash', async function () {\n const hashA = await randomHash()\n const hashB = await randomHash()\n const secureDelegationWriteA: [string, SecureDelegation] = [hashA, new SecureDelegation({ permissions: AccessLevel.WRITE })]\n const secureDelegationReadA: [string, SecureDelegation] = [hashA, new SecureDelegation({ permissions: AccessLevel.READ })]\n const secureDelegationWriteB: [string, SecureDelegation] = [hashB, new SecureDelegation({ permissions: AccessLevel.WRITE })]\n const secureDelegationReadB: [string, SecureDelegation] = [hashB, new SecureDelegation({ permissions: AccessLevel.READ })]\n const secureDelegationWriteOther: [string, SecureDelegation] = [\n await randomHash(),\n new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.WRITE }),\n ]\n const secureDelegationReadOther: [string, SecureDelegation] = [\n await randomHash(),\n new SecureDelegation({ delegator: primitives.randomUuid(), permissions: AccessLevel.READ }),\n ]\n\n async function testWithEntriesAndHashes(entries: [string, SecureDelegation][], hashes: string[], expectedLevel: AccessLevel | undefined) {\n await initialiseComponents()\n for (const hash of hashes) {\n exchangeData.cacheFakeData({} as any, { exchangeKey: {} as any, hashes: [hash] })\n }\n expect(\n await decryptor.getEntityAccessLevel(\n entityWithSecurityMetadata({\n secureDelegations: Object.fromEntries(entries),\n }),\n [primitives.randomUuid()]\n )\n ).to.equal(expectedLevel)\n }\n\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashA], AccessLevel.READ)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashB], AccessLevel.WRITE)\n await testWithEntriesAndHashes([secureDelegationWriteB, secureDelegationReadOther], [hashA], undefined)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationWriteB, secureDelegationWriteOther], [hashA, hashB], AccessLevel.WRITE)\n await testWithEntriesAndHashes([secureDelegationReadA, secureDelegationReadB, secureDelegationWriteOther], [hashA, hashB], AccessLevel.READ)\n await testWithEntriesAndHashes([secureDelegationWriteA], [hashA, hashB], AccessLevel.WRITE)\n })\n})\n"]}
|
|
@@ -23,7 +23,7 @@ const utils_1 = require("../../../icc-x-api/crypto/utils");
|
|
|
23
23
|
describe('SignatureKeysManager', () => {
|
|
24
24
|
it('should be able to store a key pair in local storage and reload it', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
25
|
const iCureStorage = new IcureStorageFacade_1.IcureStorageFacade(new TestStorage_1.TestKeyStorage(), new TestStorage_1.TestStorage(), new DefaultStorageEntryKeysFactory_1.DefaultStorageEntryKeysFactory());
|
|
26
|
-
const primitives = new CryptoPrimitives_1.
|
|
26
|
+
const primitives = new CryptoPrimitives_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
27
27
|
const dataOwnerApi = new FakeDataOwnerApi_1.FakeDataOwnerApi({ id: primitives.randomUuid(), type: DataOwnerTypeEnum_1.DataOwnerTypeEnum.Hcp });
|
|
28
28
|
const manager1 = new UserSignatureKeysManager_1.UserSignatureKeysManager(iCureStorage, dataOwnerApi, primitives);
|
|
29
29
|
const pair1 = yield manager1.getOrCreateSignatureKeyPair();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-keys-manager-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/signature-keys-manager-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iGAA6F;AAC7F,sFAAkF;AAClF,yDAAqE;AACrE,8GAA0G;AAC1G,mEAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"signature-keys-manager-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/signature-keys-manager-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iGAA6F;AAC7F,sFAAkF;AAClF,yDAAqE;AACrE,8GAA0G;AAC1G,mEAA+D;AAC/D,iFAAkG;AAClG,mCAAkC;AAClC,gFAA4E;AAC5E,kDAA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CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;QACvF,MAAM,OAAO,GAAG,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;QACvF,IAAA,aAAM,EAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjC,MAAM,aAAa,GAAG,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,QAAQ,CAAC,2BAA2B,CAAC,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC,CAAE,EAAE,MAAM,CAAC,CAAC,CAAA;QAC3I,MAAM,aAAa,GAAG,IAAA,kBAAM,EAAC,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,QAAQ,CAAC,2BAA2B,CAAC,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC,CAAE,EAAE,MAAM,CAAC,CAAC,CAAA;QAC3I,IAAA,aAAM,EAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACvC,IAAA,aAAM,EAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { UserSignatureKeysManager } from '../../../icc-x-api/crypto/UserSignatureKeysManager'\nimport { IcureStorageFacade } from '../../../icc-x-api/storage/IcureStorageFacade'\nimport { TestKeyStorage, TestStorage } from '../../utils/TestStorage'\nimport { DefaultStorageEntryKeysFactory } from '../../../icc-x-api/storage/DefaultStorageEntryKeysFactory'\nimport { FakeDataOwnerApi } from '../../utils/FakeDataOwnerApi'\nimport { CryptoPrimitives, WebCryptoPrimitives } from '../../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\nimport { DataOwnerTypeEnum } from '../../../icc-api/model/DataOwnerTypeEnum'\nimport { ua2hex } from '../../../icc-x-api'\nimport { expect } from 'chai'\nimport { fingerprintV1, fingerprintV2 } from '../../../icc-x-api/crypto/utils'\n\ndescribe('SignatureKeysManager', () => {\n it('should be able to store a key pair in local storage and reload it', async () => {\n const iCureStorage = new IcureStorageFacade(new TestKeyStorage(), new TestStorage(), new DefaultStorageEntryKeysFactory())\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const dataOwnerApi = new FakeDataOwnerApi({ id: primitives.randomUuid(), type: DataOwnerTypeEnum.Hcp })\n const manager1 = new UserSignatureKeysManager(iCureStorage, dataOwnerApi, primitives)\n const pair1 = await manager1.getOrCreateSignatureKeyPair()\n const manager2 = new UserSignatureKeysManager(iCureStorage, dataOwnerApi, primitives)\n const pair2 = await manager2.getOrCreateSignatureKeyPair()\n const private1 = ua2hex(await primitives.RSA.exportKey(pair1.keyPair.privateKey, 'pkcs8'))\n const private2 = ua2hex(await primitives.RSA.exportKey(pair2.keyPair.privateKey, 'pkcs8'))\n expect(private1).to.equal(private2)\n const public1 = ua2hex(await primitives.RSA.exportKey(pair1.keyPair.publicKey, 'spki'))\n const public2 = ua2hex(await primitives.RSA.exportKey(pair2.keyPair.publicKey, 'spki'))\n expect(public1).to.equal(public2)\n const verification1 = ua2hex(await primitives.RSA.exportKey((await manager1.getSignatureVerificationKey(fingerprintV2(public1)))!, 'spki'))\n const verification2 = ua2hex(await primitives.RSA.exportKey((await manager2.getSignatureVerificationKey(fingerprintV2(public1)))!, 'spki'))\n expect(verification1).to.equal(public1)\n expect(verification2).to.equal(public1)\n })\n})\n"]}
|
|
@@ -44,7 +44,7 @@ describe('icc-x-user-api Tests', () => {
|
|
|
44
44
|
yield api.userApi.getCurrentUser();
|
|
45
45
|
}));
|
|
46
46
|
it('Can get an user by its phoneNumber', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const primitives = new icc_x_api_1.
|
|
47
|
+
const primitives = new icc_x_api_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
48
48
|
const phoneNumber = `+${primitives.randomUuid()}`;
|
|
49
49
|
const api = yield initMasterApi(env);
|
|
50
50
|
const createdUser = yield api.userApi.createUser(new User_1.User({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-user-x-api-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-user-x-api-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAoI;AACpI,iCAA8B;AAC9B,mDAA0C;AAC1C,8CAA0C;AAC1C,mDAAmE;AACnE,+
|
|
1
|
+
{"version":3,"file":"icc-user-x-api-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-user-x-api-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oDAAoI;AACpI,iCAA8B;AAC9B,mDAA0C;AAC1C,8CAA0C;AAC1C,mDAAmE;AACnE,+CAAsI;AACtI,mCAAkC;AAClC,+BAAqC;AACrC,mDAA+C;AAC/C,+BAAiC;AACjC,IAAO,aAAa,GAAG,sBAAS,CAAC,aAAa,CAAA;AAC9C,8EAA6G;AAC7G,mCAAmC;AACnC,2CAAsD;AAEtD,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AACjB,IAAI,OAAmB,CAAA;AAEvB,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAA,cAAM,EAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;YAClD,OAAO,GAAG,IAAI,oBAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,oCAAwB,EAAE,EAAE,KAAK,CAAC,CA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TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { crypto } from '../../node-compat'\nimport { TestApi } from '../utils/TestApi'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { AuthenticationProvider, CryptoPrimitives, WebCryptoPrimitives, IccUserXApi, NoAuthenticationProvider } from '../../icc-x-api'\nimport { webcrypto } from 'crypto'\nimport { assert, expect } from 'chai'\nimport { User } from '../../icc-api/model/User'\nimport { v4 as uuid } from 'uuid'\nimport initMasterApi = TestUtils.initMasterApi\nimport { AuthSecretDetails, AuthSecretType, SmartAuthProvider } from '../../icc-x-api/auth/SmartAuthProvider'\nimport { randomUUID } from 'crypto'\nimport { IccAuthApi, IccUserApi } from '../../icc-api'\n\nsetLocalStorage(fetch)\nlet env: TestVars\nlet authApi: IccAuthApi\n\ndescribe('icc-x-user-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n authApi = new IccAuthApi(env.iCureUrl, {}, new NoAuthenticationProvider(), fetch)\n })\n\n function userApiWithProvider(authProvider: AuthenticationProvider): IccUserApi {\n return new IccUserXApi(env.iCureUrl, {}, authProvider, new IccAuthApi(env.iCureUrl, {}, new NoAuthenticationProvider(), fetch))\n }\n\n it('Can instantiate an API and get the current user', async () => {\n // Given\n const api = await TestApi(env.iCureUrl, env.dataOwnerDetails[hcp1Username].user, env.dataOwnerDetails[hcp1Username].password, crypto)\n await api.userApi.getCurrentUser()\n })\n\n it('Can get an user by its phoneNumber', async () => {\n const primitives = new WebCryptoPrimitives(webcrypto as any)\n const phoneNumber = `+${primitives.randomUuid()}`\n\n const api = await initMasterApi(env)\n\n const createdUser = await api.userApi.createUser(\n new User({\n id: uuid(),\n name: `user-${primitives.randomUuid()}`,\n login: `user-${primitives.randomUuid()}`,\n email: `user-${primitives.randomUuid()}@icure.com`,\n mobilePhone: phoneNumber,\n })\n )\n\n const user = await api.userApi.getUserByPhoneNumber(phoneNumber)\n\n expect(user).to.be.deep.equal(createdUser)\n })\n\n itNoLite(\n 'Should automatically ask for a more powerful secret to perform elevated-security operations if the available secret/token is not good enough. When a new token is created during this process, the modifyUser does not fail with a 409',\n async () => {\n const { credentials, api } = await createNewHcpApi(env)\n const initialUser = await api.userApi.getCurrentUser()\n const masterApi = await initMasterApi(env)\n const userToken = randomUUID()\n const userWithLongToken = await masterApi.userApi.modifyUser({\n ...initialUser,\n authenticationTokens: {\n 'test-long-lived-token': {\n token: userToken,\n creationTime: Date.now(),\n validity: 60 * 60 * 24 * 7,\n },\n },\n })\n let longLivedTokenRequested = false\n let shortLivedTokenRequested = false\n const authProvider = SmartAuthProvider.initialise(authApi, credentials.user, {\n getSecret: async (acceptedSecrets: AuthSecretType[], previousAttempts: AuthSecretDetails[]) => {\n if (acceptedSecrets.includes(AuthSecretType.LONG_LIVED_TOKEN)) {\n longLivedTokenRequested = true\n return { value: userToken, secretType: AuthSecretType.LONG_LIVED_TOKEN }\n } else if (acceptedSecrets.includes(AuthSecretType.SHORT_LIVED_TOKEN)) {\n shortLivedTokenRequested = true\n await masterApi.userApi.getToken(userWithLongToken.id!, 'tmp', 300, '123456')\n return { value: '123456', secretType: AuthSecretType.SHORT_LIVED_TOKEN }\n } else assert.fail('Should request LONG_LIVED_TOKEN or SHORT_LIVED_TOKEN')\n },\n })\n const userApi = userApiWithProvider(authProvider)\n expect((await userApi.getCurrentUser()).rev).to.equal(userWithLongToken.rev)\n expect(longLivedTokenRequested).to.be.true\n expect(shortLivedTokenRequested).to.be.false\n\n const newPw = randomUUID()\n const userWithNewPw = await userApi.modifyUser({ ...userWithLongToken, passwordHash: newPw })\n\n expect(userWithNewPw.rev).to.not.equal(userWithLongToken.rev)\n expect(shortLivedTokenRequested).to.be.true\n }\n )\n})\n"]}
|
|
@@ -36,7 +36,7 @@ function checkEncryptedData(actual, expected, actualName) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
(0, test_utils_1.setLocalStorage)(fetch);
|
|
39
|
-
const cryptoPrimitives = new icc_x_api_1.
|
|
39
|
+
const cryptoPrimitives = new icc_x_api_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
40
40
|
let env;
|
|
41
41
|
class ApiFactoryV6 {
|
|
42
42
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-legacy-data-support.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-legacy-data-support.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,wCAA2D;AAC3D,wCAAkJ;AAClJ,+CASwB;AACxB,oDAAgF;AAEhF,+BAA6B;AAC7B,mCAAkC;AAElC,+BAAiC;AACjC,yEAAqE;AACrE,sDAAuF;AACvF,wEAAoE;AACpE,wFAAoF;AACpF,mDAAmE;AACnE,wDAAiG;AACjG,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AA+B3E,SAAS,kBAAkB,CAAC,MAAqB,EAAE,QAAuB,EAAE,UAAkB;IAC5F,IAAA,aAAM,EAAC,MAAM,CAAC,aAAa,EAAE,GAAG,UAAU,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC/F,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAChG,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,SAAS,EAAE;QAC3C,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,cAAc,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;KAC7E;IACD,IAAA,aAAM,EAAC,MAAM,CAAC,eAAe,EAAE,GAAG,UAAU,qBAAqB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAA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BAC/D,kBAAkB,CAAC,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,6CAA6C,OAAO,GAAG,CAAC,CAAA;wBACnI,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAA;wBAChG,kBAAkB,CAAC,MAAM,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,+BAA+B,OAAO,GAAG,CAAC,CAAA;qBAChH;oBACD,kBAAkB,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,2CAA2C,CAAC,CAAA;gBACtH,CAAC;aAAA,CAAC,CAAA;SACH;IACH,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { Api as ApiV6, User as UserV6 } from '@icure/apiV6'\nimport { CryptoStrategies as CryptoStrategiesV7, DataOwnerWithType as DataOwnerWithTypeV7, IcureApi as ApiV7, User as UserV7 } from '@icure/apiV7'\nimport {\n CryptoPrimitivesImpl,\n EntityWithDelegationTypeName,\n hex2ua,\n IcureApi as ApiV8,\n RSAUtils,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n} from '../../icc-x-api'\nimport { getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { expect } from 'chai'\nimport { webcrypto } from 'crypto'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { v4 as uuid } from 'uuid'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from '../../icc-x-api/crypto/utils'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\ntype UserCredentials = {\n login: string\n password: string\n ownerId: string\n key: KeyPair<CryptoKey>\n}\ntype EncryptedData = {\n secretContent: string\n secretIds: string[]\n owningEntityIds: string[]\n}\n\ninterface UniformizedMasterApi {\n createUser(): Promise<UserCredentials>\n}\n\ninterface UniformizedTestApi {\n userDetails(): Promise<{ userId: string; dataOwnerId: string }>\n createEncryptedData(): Promise<{ id: string } & EncryptedData>\n getDecryptedData(id: string): Promise<EncryptedData>\n shareEncryptedData(dataId: string, delegateId: string): Promise<void>\n}\n\ninterface ApiFactory {\n readonly version: string\n masterApi(env: TestVars): Promise<UniformizedMasterApi>\n testApi(credentials: UserCredentials): Promise<UniformizedTestApi>\n}\n\nfunction checkEncryptedData(actual: EncryptedData, expected: EncryptedData, actualName: string) {\n expect(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent)\n expect(actual.secretIds, `${actualName} - secret ids`).to.have.length(expected.secretIds.length)\n for (const expectedId of expected.secretIds) {\n expect(actual.secretIds, `${actualName} - secret id`).to.contain(expectedId)\n }\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(expected.owningEntityIds.length)\n for (const expectedId of expected.owningEntityIds) {\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.contain(expectedId)\n }\n}\n\nsetLocalStorage(fetch)\nconst cryptoPrimitives = new CryptoPrimitivesImpl(webcrypto as any)\nlet env: TestVars\n\nclass ApiFactoryV6 implements ApiFactory {\n readonly version: string = 'apiV6.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const apis = await ApiV6(\n env.iCureUrl + '/rest/v1',\n env.masterHcp!.user,\n env.masterHcp!.password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v6' }))\n const user = await apis.userApi.createUser(\n new UserV6({\n id: uuid(),\n login: `v6-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const apis = await ApiV6(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, webcrypto as any, fetch)\n // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, \"jwk\", \"jwk\"))\n const user = await apis.userApi.getCurrentUser()\n await apis.cryptoApi.addKeyPairForOwner(\n apis.maintenanceTaskApi,\n user,\n await apis.cryptoApi.getDataOwner(credentials.ownerId),\n credentials.key,\n false,\n false\n )\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v6 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: (await apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const patientIds = (await apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(patientIds).to.have.length(1)\n const patient = await apis.patientApi.getPatientWithUser(user, patientIds[0])\n const secretIds = (await apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(secretIds).to.have.length(1)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n (\n await apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])\n ).modifiedObject\n )\n },\n }\n }\n}\n\nclass TestCryptoStrategiesV7 implements CryptoStrategiesV7 {\n private readonly RSA = new RSAUtilsImpl(webcrypto as any)\n constructor(private readonly key: KeyPair<CryptoKey> | undefined) {}\n\n async generateNewKeyForDataOwner(self: DataOwnerWithTypeV7): Promise<KeyPair<CryptoKey> | boolean> {\n if (!this.key) return false\n const knownKeys = new Set(...hexPublicKeysWithSha1Of(self))\n if (knownKeys.size <= 0) return this.key\n return false\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithTypeV7\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n const self = keysData[keysData.length - 1].dataOwner\n const knownKeys = new Set([...hexPublicKeysWithSha1Of(self.dataOwner), ...hexPublicKeysWithSha256Of(self.dataOwner)])\n const publicKey = this.key ? ua2hex(await this.RSA.exportKey(this.key.publicKey, 'spki')) : undefined\n return Object.fromEntries(\n await Promise.all(\n keysData.map(async (currData) => {\n if (currData.dataOwner.dataOwner.id! !== self.dataOwner.id!) {\n return [\n currData.dataOwner.dataOwner.id!,\n {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n ]\n } else if (publicKey === undefined || !knownKeys.has(publicKey)) {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: {}, keyAuthenticity: {} }]\n } else {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: { [publicKey.slice(-32)]: this.key }, keyAuthenticity: {} }]\n }\n })\n )\n )\n }\n\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\nclass ApiFactoryV7 implements ApiFactory {\n readonly version: string = 'apiV7.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategiesV7(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategiesV7(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v7 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthdata)\n expect(secretIds).to.have.length(1)\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.entities.secretIdsOf(healthdata),\n owningEntityIds: await apis.cryptoApi.entities.owningEntityIdsOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const encryptionKeys = await apis.cryptoApi.entities.encryptionKeysOf(healthElement)\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthElement)\n const owningEntityIds = await apis.cryptoApi.entities.owningEntityIdsOf(healthElement)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n await apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, [])\n )\n },\n }\n }\n}\n\nclass ApiFactoryV8 implements ApiFactory {\n readonly version: string = 'apiV8.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategies(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategies(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v8 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: [],\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.xapi.secretIdsOf({ entity: healthdata, type: EntityWithDelegationTypeName.HealthElement }, undefined),\n owningEntityIds: await apis.healthcareElementApi.decryptPatientIdOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n await apis.healthcareElementApi.shareWith(delegateId, healthElement, { requestedPermissions: RequestedPermissionEnum.MAX_WRITE })\n },\n }\n }\n}\n\n// Api factories in chronological version order\nlet chronologicalApiFactories: ApiFactory[] = [new ApiFactoryV6(), new ApiFactoryV7(), new ApiFactoryV8()]\n\ndescribe('All apis versions', async function () {\n before(async function () {\n this.timeout(600_000)\n env = await getEnvironmentInitializer().then((initializer) => initializer.execute(getEnvVariables()))\n })\n\n for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {\n const legacyApiFactory = chronologicalApiFactories[legacyApiIndex]\n const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1)\n it(`should be able to read and share data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, async function () {\n const legacyMasterApi = await legacyApiFactory.masterApi(env)\n const legacyUserCredentials = await legacyMasterApi.createUser()\n const legacyUserApi = await legacyApiFactory.testApi(legacyUserCredentials)\n const data = await legacyUserApi.createEncryptedData()\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data')\n const newApis = await Promise.all(\n newApiFactories.map(async (factory) => {\n const newLegacyUserApi = await factory.testApi(legacyUserCredentials)\n const newUser = await factory.masterApi(env).then((masterApi) => masterApi.createUser())\n const newUserApi = await factory.testApi(newUser)\n return { newLegacyUserApi, newUserApi, version: factory.version }\n })\n )\n for (const { newLegacyUserApi, newUserApi, version } of newApis) {\n checkEncryptedData(await newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`)\n await newLegacyUserApi.shareEncryptedData(data.id, (await newUserApi.userDetails()).dataOwnerId)\n checkEncryptedData(await newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`)\n }\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`)\n })\n }\n})\n"]}
|
|
1
|
+
{"version":3,"file":"test-legacy-data-support.js","sourceRoot":"","sources":["../../../test/icc-x-api/test-legacy-data-support.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,wCAA2D;AAC3D,wCAAkJ;AAClJ,+CASwB;AACxB,oDAAgF;AAEhF,+BAA6B;AAC7B,mCAAkC;AAElC,+BAAiC;AACjC,yEAAqE;AACrE,sDAAuF;AACvF,wEAAoE;AACpE,wFAAoF;AACpF,mDAAmE;AACnE,wDAAiG;AACjG,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AA+B3E,SAAS,kBAAkB,CAAC,MAAqB,EAAE,QAAuB,EAAE,UAAkB;IAC5F,IAAA,aAAM,EAAC,MAAM,CAAC,aAAa,EAAE,GAAG,UAAU,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC/F,IAAA,aAAM,EAAC,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,C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EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAA;wBACxF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;wBACjD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAA;oBACnE,CAAC,CAAA,CAAC,CACH,CAAA;oBACD,KAAK,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE;wBAC/D,kBAAkB,CAAC,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,6CAA6C,OAAO,GAAG,CAAC,CAAA;wBACnI,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAA;wBAChG,kBAAkB,CAAC,MAAM,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,+BAA+B,OAAO,GAAG,CAAC,CAAA;qBAChH;oBACD,kBAAkB,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,2CAA2C,CAAC,CAAA;gBACtH,CAAC;aAAA,CAAC,CAAA;SACH;IACH,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { Api as ApiV6, User as UserV6 } from '@icure/apiV6'\nimport { CryptoStrategies as CryptoStrategiesV7, DataOwnerWithType as DataOwnerWithTypeV7, IcureApi as ApiV7, User as UserV7 } from '@icure/apiV7'\nimport {\n WebCryptoPrimitives,\n EntityWithDelegationTypeName,\n hex2ua,\n IcureApi as ApiV8,\n RSAUtils,\n RSAUtilsImpl,\n ShaVersion,\n ua2hex,\n} from '../../icc-x-api'\nimport { getEnvironmentInitializer, setLocalStorage } from '../utils/test_utils'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { expect } from 'chai'\nimport { webcrypto } from 'crypto'\nimport { CryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { v4 as uuid } from 'uuid'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../utils/TestStorage'\nimport { TestCryptoStrategies } from '../utils/TestCryptoStrategies'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from '../../icc-x-api/crypto/utils'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\ntype UserCredentials = {\n login: string\n password: string\n ownerId: string\n key: KeyPair<CryptoKey>\n}\ntype EncryptedData = {\n secretContent: string\n secretIds: string[]\n owningEntityIds: string[]\n}\n\ninterface UniformizedMasterApi {\n createUser(): Promise<UserCredentials>\n}\n\ninterface UniformizedTestApi {\n userDetails(): Promise<{ userId: string; dataOwnerId: string }>\n createEncryptedData(): Promise<{ id: string } & EncryptedData>\n getDecryptedData(id: string): Promise<EncryptedData>\n shareEncryptedData(dataId: string, delegateId: string): Promise<void>\n}\n\ninterface ApiFactory {\n readonly version: string\n masterApi(env: TestVars): Promise<UniformizedMasterApi>\n testApi(credentials: UserCredentials): Promise<UniformizedTestApi>\n}\n\nfunction checkEncryptedData(actual: EncryptedData, expected: EncryptedData, actualName: string) {\n expect(actual.secretContent, `${actualName} - secret content`).to.equal(expected.secretContent)\n expect(actual.secretIds, `${actualName} - secret ids`).to.have.length(expected.secretIds.length)\n for (const expectedId of expected.secretIds) {\n expect(actual.secretIds, `${actualName} - secret id`).to.contain(expectedId)\n }\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.have.length(expected.owningEntityIds.length)\n for (const expectedId of expected.owningEntityIds) {\n expect(actual.owningEntityIds, `${actualName} - owning entity id`).to.contain(expectedId)\n }\n}\n\nsetLocalStorage(fetch)\nconst cryptoPrimitives = new WebCryptoPrimitives(webcrypto as any)\nlet env: TestVars\n\nclass ApiFactoryV6 implements ApiFactory {\n readonly version: string = 'apiV6.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const apis = await ApiV6(\n env.iCureUrl + '/rest/v1',\n env.masterHcp!.user,\n env.masterHcp!.password,\n webcrypto as any,\n fetch,\n false,\n false,\n new TestStorage(),\n new TestKeyStorage()\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v6' }))\n const user = await apis.userApi.createUser(\n new UserV6({\n id: uuid(),\n login: `v6-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const apis = await ApiV6(env.iCureUrl + '/rest/v1', credentials.login, credentials.password, webcrypto as any, fetch)\n // await apis.cryptoApi.cacheKeyPair(await cryptoPrimitives.RSA.exportKeys(credentials.key, \"jwk\", \"jwk\"))\n const user = await apis.userApi.getCurrentUser()\n await apis.cryptoApi.addKeyPairForOwner(\n apis.maintenanceTaskApi,\n user,\n await apis.cryptoApi.getDataOwner(credentials.ownerId),\n credentials.key,\n false,\n false\n )\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v6 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: (await apis.cryptoApi.extractDelegationsSFKs(healthdata, credentials.ownerId)).extractedKeys,\n owningEntityIds: (await apis.cryptoApi.extractCryptedFKs(healthdata, credentials.ownerId)).extractedKeys,\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const patientIds = (await apis.cryptoApi.extractCryptedFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(patientIds).to.have.length(1)\n const patient = await apis.patientApi.getPatientWithUser(user, patientIds[0])\n const secretIds = (await apis.cryptoApi.extractDelegationsSFKs(healthElement, credentials.ownerId)).extractedKeys\n expect(secretIds).to.have.length(1)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n (\n await apis.cryptoApi.extendedDelegationsAndCryptedForeignKeys(healthElement, patient, credentials.ownerId, delegateId, secretIds[0])\n ).modifiedObject\n )\n },\n }\n }\n}\n\nclass TestCryptoStrategiesV7 implements CryptoStrategiesV7 {\n private readonly RSA = new RSAUtilsImpl(webcrypto as any)\n constructor(private readonly key: KeyPair<CryptoKey> | undefined) {}\n\n async generateNewKeyForDataOwner(self: DataOwnerWithTypeV7): Promise<KeyPair<CryptoKey> | boolean> {\n if (!this.key) return false\n const knownKeys = new Set(...hexPublicKeysWithSha1Of(self))\n if (knownKeys.size <= 0) return this.key\n return false\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithTypeV7\n unknownKeys: string[]\n unavailableKeys: string[]\n }[]\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n const self = keysData[keysData.length - 1].dataOwner\n const knownKeys = new Set([...hexPublicKeysWithSha1Of(self.dataOwner), ...hexPublicKeysWithSha256Of(self.dataOwner)])\n const publicKey = this.key ? ua2hex(await this.RSA.exportKey(this.key.publicKey, 'spki')) : undefined\n return Object.fromEntries(\n await Promise.all(\n keysData.map(async (currData) => {\n if (currData.dataOwner.dataOwner.id! !== self.dataOwner.id!) {\n return [\n currData.dataOwner.dataOwner.id!,\n {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n ]\n } else if (publicKey === undefined || !knownKeys.has(publicKey)) {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: {}, keyAuthenticity: {} }]\n } else {\n return [currData.dataOwner.dataOwner.id!, { recoveredKeys: { [publicKey.slice(-32)]: this.key }, keyAuthenticity: {} }]\n }\n })\n )\n )\n }\n\n verifyDelegatePublicKeys(delegate: any, publicKeys: string[]): Promise<string[]> {\n return Promise.resolve(publicKeys)\n }\n}\nclass ApiFactoryV7 implements ApiFactory {\n readonly version: string = 'apiV7.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategiesV7(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha1)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV7.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategiesV7(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v7 note ${uuid}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthdata)\n expect(secretIds).to.have.length(1)\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds,\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.entities.secretIdsOf(healthdata),\n owningEntityIds: await apis.cryptoApi.entities.owningEntityIdsOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n const encryptionKeys = await apis.cryptoApi.entities.encryptionKeysOf(healthElement)\n const secretIds = await apis.cryptoApi.entities.secretIdsOf(healthElement)\n const owningEntityIds = await apis.cryptoApi.entities.owningEntityIdsOf(healthElement)\n await apis.healthcareElementApi.modifyHealthElementWithUser(\n user,\n await apis.cryptoApi.entities.entityWithExtendedEncryptedMetadata(healthElement, delegateId, secretIds, encryptionKeys, owningEntityIds, [])\n )\n },\n }\n }\n}\n\nclass ApiFactoryV8 implements ApiFactory {\n readonly version: string = 'apiV8.x'\n\n async masterApi(env: TestVars): Promise<UniformizedMasterApi> {\n const key = {\n privateKey: await cryptoPrimitives.RSA.importKey('pkcs8', hex2ua(env.masterHcp!.privateKey), ['decrypt'], ShaVersion.Sha1),\n publicKey: await cryptoPrimitives.RSA.importKey('spki', hex2ua(env.masterHcp!.publicKey), ['encrypt'], ShaVersion.Sha1),\n }\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n { username: env.masterHcp!.user, password: env.masterHcp!.password },\n new TestCryptoStrategies(key),\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n return <UniformizedMasterApi>{\n createUser: async () => {\n const pair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256)\n const hcp = await apis.healthcarePartyApi.createHealthcareParty(new HealthcareParty({ id: uuid(), firstName: `name`, lastName: 'v7' }))\n const user = await apis.userApi.createUser(\n new UserV7({\n id: uuid(),\n login: `v7-${uuid()}`,\n status: 'ACTIVE',\n healthcarePartyId: hcp.id,\n })\n )\n return {\n login: user.login,\n password: await apis.userApi.getToken(user.id!, uuid()),\n key: pair,\n ownerId: hcp.id,\n }\n },\n }\n }\n\n async testApi(credentials: UserCredentials): Promise<UniformizedTestApi> {\n const testStorage = await testStorageWithKeys([\n {\n dataOwnerId: credentials.ownerId,\n pairs: [\n {\n keyPair: {\n publicKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.publicKey, 'spki')),\n privateKey: ua2hex(await cryptoPrimitives.RSA.exportKey(credentials.key.privateKey, 'pkcs8')),\n },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const apis = await ApiV8.initialise(\n env.iCureUrl,\n {\n username: credentials.login,\n password: credentials.password,\n },\n new TestCryptoStrategies(credentials.key),\n webcrypto as any,\n fetch,\n {\n storage: testStorage.storage,\n keyStorage: testStorage.keyStorage,\n entryKeysFactory: testStorage.keyFactory,\n }\n )\n const user = await apis.userApi.getCurrentUser()\n return {\n userDetails: async () => {\n return { userId: user.id!, dataOwnerId: credentials.ownerId }\n },\n createEncryptedData: async () => {\n const note = `v8 note ${uuid()}`\n const patient = await apis.patientApi.createPatientWithUser(user, await apis.patientApi.newInstance(user))\n const healthdata = await apis.healthcareElementApi.createHealthElementWithUser(\n user,\n await apis.healthcareElementApi.newInstance(user, patient, { note })\n )\n return {\n id: healthdata.id,\n secretContent: note,\n secretIds: [],\n owningEntityIds: [patient.id! as string],\n }\n },\n getDecryptedData: async (id) => {\n const healthdata = await apis.healthcareElementApi.getHealthElementWithUser(user, id)\n return {\n secretContent: healthdata.note!,\n secretIds: await apis.cryptoApi.xapi.secretIdsOf({ entity: healthdata, type: EntityWithDelegationTypeName.HealthElement }, undefined),\n owningEntityIds: await apis.healthcareElementApi.decryptPatientIdOf(healthdata),\n }\n },\n shareEncryptedData: async (dataId, delegateId) => {\n const healthElement = await apis.healthcareElementApi.getHealthElementWithUser(user, dataId)\n await apis.healthcareElementApi.shareWith(delegateId, healthElement, { requestedPermissions: RequestedPermissionEnum.MAX_WRITE })\n },\n }\n }\n}\n\n// Api factories in chronological version order\nlet chronologicalApiFactories: ApiFactory[] = [new ApiFactoryV6(), new ApiFactoryV7(), new ApiFactoryV8()]\n\ndescribe('All apis versions', async function () {\n before(async function () {\n this.timeout(600_000)\n env = await getEnvironmentInitializer().then((initializer) => initializer.execute(getEnvVariables()))\n })\n\n for (let legacyApiIndex = 0; legacyApiIndex < chronologicalApiFactories.length - 1; legacyApiIndex++) {\n const legacyApiFactory = chronologicalApiFactories[legacyApiIndex]\n const newApiFactories = chronologicalApiFactories.slice(legacyApiIndex + 1)\n it(`should be able to read and share data from older apis without affecting accessibility for older apis - ${legacyApiFactory.version}`, async function () {\n const legacyMasterApi = await legacyApiFactory.masterApi(env)\n const legacyUserCredentials = await legacyMasterApi.createUser()\n const legacyUserApi = await legacyApiFactory.testApi(legacyUserCredentials)\n const data = await legacyUserApi.createEncryptedData()\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, 'Original decrypted data')\n const newApis = await Promise.all(\n newApiFactories.map(async (factory) => {\n const newLegacyUserApi = await factory.testApi(legacyUserCredentials)\n const newUser = await factory.masterApi(env).then((masterApi) => masterApi.createUser())\n const newUserApi = await factory.testApi(newUser)\n return { newLegacyUserApi, newUserApi, version: factory.version }\n })\n )\n for (const { newLegacyUserApi, newUserApi, version } of newApis) {\n checkEncryptedData(await newLegacyUserApi.getDecryptedData(data.id), data, `Data decrypted by legacy user on new api (${version})`)\n await newLegacyUserApi.shareEncryptedData(data.id, (await newUserApi.userDetails()).dataOwnerId)\n checkEncryptedData(await newUserApi.getDecryptedData(data.id), data, `Data decrypted by new user (${version})`)\n }\n checkEncryptedData(await legacyUserApi.getDecryptedData(data.id), data, `Data after changes by new versions of api`)\n })\n }\n})\n"]}
|
|
@@ -21,7 +21,7 @@ class FakeDataOwnerApi extends icc_data_owner_x_api_1.IccDataOwnerXApi {
|
|
|
21
21
|
constructor(self, others = []) {
|
|
22
22
|
super('fake', {}, null, null);
|
|
23
23
|
this.data = new FakeGenericApi_1.FakeGenericApi();
|
|
24
|
-
this.primitives = new CryptoPrimitives_1.
|
|
24
|
+
this.primitives = new CryptoPrimitives_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
25
25
|
this.selfId = self.id;
|
|
26
26
|
this.data.createObject(self);
|
|
27
27
|
others.forEach((x) => this.data.createObject(x));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeDataOwnerApi.js","sourceRoot":"","sources":["../../../test/utils/FakeDataOwnerApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAmG;AACnG,qDAAiD;AAKjD,
|
|
1
|
+
{"version":3,"file":"FakeDataOwnerApi.js","sourceRoot":"","sources":["../../../test/utils/FakeDataOwnerApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAAmG;AACnG,qDAAiD;AAKjD,8EAA+F;AAC/F,mCAAkC;AAClC,+CAAwC;AACxC,6EAAyE;AAEzE,yEAA6E;AAG7E,MAAa,gBAAiB,SAAQ,uCAAgB;IAKpD,YAAY,IAA6C,EAAE,SAAsD,EAAE;QACjH,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,IAAW,EAAE,IAAW,CAAC,CAAA;QAJ5B,SAAI,GAAG,IAAI,+BAAc,EAA2C,CAAA;QACpE,eAAU,GAAG,IAAI,sCAAmB,CAAC,kBAAgB,CAAC,CAAA;QAIrE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAG,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAEK,qBAAqB;;YACzB,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;KAAA;IAEK,+BAA+B;;YACnC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACvB,IAAI,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAChD,OAAO,WAAW,IAAK,WAAmB,CAAC,QAAQ,EAAE;gBACnD,MAAM,MAAM,GAAY,WAAmB,CAAC,QAAQ,CAAA;gBACpD,WAAW,GAAG,IAAI,CAAC,IAAI,CA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;YACxF,MAAM,IAAI,CAAC,qBAAqB,CAAC;gBAC/B,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,IAAI,kCACC,SAAS,CAAC,IAAI,KACjB,2BAA2B,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,2BAA2B,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,GAChG;aACF,CAAC,CAAA;QACJ,CAAC;KAAA;IAEO,SAAS,CAAC,CAA0C;QAC1D,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAA;QACnB,OAAQ,CAAS,CAAC,IAAI,CAAA;QACtB,IAAI,IAAI,KAAK,qCAAiB,CAAC,OAAO,EAAE;YACtC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAY,EAAE,CAAA;SACzC;aAAM,IAAI,IAAI,KAAK,qCAAiB,CAAC,MAAM,EAAE;YAC5C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAW,EAAE,CAAA;SACxC;aAAM,IAAI,IAAI,KAAK,qCAAiB,CAAC,GAAG,EAAE;YACzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAoB,EAAE,CAAA;SACjD;;YAAM,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAC3D,CAAC;CACF;AA1GD,4CA0GC","sourcesContent":["import { DataOwner, DataOwnerOrStub, IccDataOwnerXApi } from '../../icc-x-api/icc-data-owner-x-api'\nimport { FakeGenericApi } from './FakeGenericApi'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { Device } from '../../icc-api/model/Device'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { KeyPair } from '../../icc-x-api/crypto/RSA'\nimport { CryptoPrimitives, WebCryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\nimport { ua2hex } from '../../icc-x-api'\nimport { DataOwnerTypeEnum } from '../../icc-api/model/DataOwnerTypeEnum'\nimport { DataOwnerWithType } from '../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStubWithType } from '../../icc-api/model/CryptoActorStub'\nimport { User } from '../../icc-api/model/User'\n\nexport class FakeDataOwnerApi extends IccDataOwnerXApi {\n private readonly selfId: string\n private readonly data = new FakeGenericApi<DataOwner & { type: DataOwnerTypeEnum }>()\n private readonly primitives = new WebCryptoPrimitives(webcrypto as any)\n\n constructor(self: DataOwner & { type: DataOwnerTypeEnum }, others: (DataOwner & { type: DataOwnerTypeEnum })[] = []) {\n super('fake', {}, null as any, null as any)\n this.selfId = self.id!\n this.data.createObject(self)\n others.forEach((x) => this.data.createObject(x))\n }\n\n async getCurrentDataOwnerId(): Promise<string> {\n return this.selfId\n }\n\n async getCurrentDataOwnerHierarchyIds(): Promise<string[]> {\n let res = [this.selfId]\n let latestCheck = this.data.getById(this.selfId)\n while (latestCheck && (latestCheck as any).parentId) {\n const currId: string = (latestCheck as any).parentId\n latestCheck = this.data.getById(currId)!\n res = [currId, ...res]\n }\n return res\n }\n\n async getCurrentDataOwnerHierarchyIdsFrom(parentId: string): Promise<string[]> {\n const res = []\n for (const dataOwnerId of await this.getCurrentDataOwnerHierarchyIds()) {\n res.push(dataOwnerId)\n if (dataOwnerId === parentId) return res\n }\n throw new Error(`${parentId} is not part of the data owner hierarchy for the current user`)\n }\n\n async getCurrentDataOwner(): Promise<DataOwnerWithType> {\n return this.mapObject(this.data.getById(this.selfId)!)\n }\n\n async getCurrentDataOwnerHierarchy(): Promise<DataOwnerWithType[]> {\n return (await this.getCurrentDataOwnerHierarchyIds()).map((id) => this.mapObject(this.data.getById(id)!))\n }\n\n async getCurrentDataOwnerType(): Promise<DataOwnerTypeEnum> {\n return this.data.getById(this.selfId)!.type\n }\n\n getHexPublicKeysWithSha1Of(dataOwner: DataOwnerOrStub): Set<string> {\n return super.getHexPublicKeysWithSha1Of(dataOwner)\n }\n\n getHexPublicKeysWithSha256Of(dataOwner: DataOwnerOrStub): Set<string> {\n return super.getHexPublicKeysWithSha256Of(dataOwner)\n }\n\n async getCurrentDataOwnerStub(): Promise<CryptoActorStubWithType> {\n return CryptoActorStubWithType.fromDataOwner(await this.getCurrentDataOwner())\n }\n\n getDataOwnerIdOf(user: User): string {\n return super.getDataOwnerIdOf(user)\n }\n\n async getDataOwner(ownerId: string): Promise<DataOwnerWithType> {\n return this.mapObject(this.data.getById(ownerId)!)\n }\n\n clearCurrentDataOwnerIdsCache() {\n super.clearCurrentDataOwnerIdsCache()\n }\n\n async modifyCryptoActorStub(stub: CryptoActorStubWithType): Promise<CryptoActorStubWithType> {\n const existing = this.data.getById(stub.stub.id!)\n if (!existing) throw new Error('Data owner not found.')\n if (existing.type !== stub.type) throw new Error('Unexpected type for data owner.')\n return CryptoActorStubWithType.fromDataOwner(this.mapObject(this.data.modifyObject({ ...existing, ...stub.stub })))\n }\n\n async getCryptoActorStub(ownerId: string): Promise<CryptoActorStubWithType> {\n return CryptoActorStubWithType.fromDataOwner(await this.getDataOwner(ownerId))\n }\n\n async addPublicKeyForOwner(dataOwnerId: string, keyPair: KeyPair<CryptoKey>) {\n const retrieved = await this.getCryptoActorStub(dataOwnerId)\n const publicHex = ua2hex(await this.primitives.RSA.exportKey(keyPair.publicKey, 'spki'))\n await this.modifyCryptoActorStub({\n type: retrieved.type,\n stub: {\n ...retrieved.stub,\n publicKeysForOaepWithSha256: [...(retrieved.stub.publicKeysForOaepWithSha256 || []), publicHex],\n },\n })\n }\n\n private mapObject(x: DataOwner & { type: DataOwnerTypeEnum }): DataOwnerWithType {\n const type = x.type\n delete (x as any).type\n if (type === DataOwnerTypeEnum.Patient) {\n return { type, dataOwner: x as Patient }\n } else if (type === DataOwnerTypeEnum.Device) {\n return { type, dataOwner: x as Device }\n } else if (type === DataOwnerTypeEnum.Hcp) {\n return { type, dataOwner: x as HealthcareParty }\n } else throw new Error('Unexpected type for data owner.')\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ const crypto_1 = require("crypto");
|
|
|
7
7
|
class FakeGenericApi {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.data = new Map();
|
|
10
|
-
this.primitives = new CryptoPrimitives_1.
|
|
10
|
+
this.primitives = new CryptoPrimitives_1.WebCryptoPrimitives(crypto_1.webcrypto);
|
|
11
11
|
}
|
|
12
12
|
createObject(obj) {
|
|
13
13
|
if (!obj.id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeGenericApi.js","sourceRoot":"","sources":["../../../test/utils/FakeGenericApi.ts"],"names":[],"mappings":";;;AAAA,4BAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"FakeGenericApi.js","sourceRoot":"","sources":["../../../test/utils/FakeGenericApi.ts"],"names":[],"mappings":";;;AAAA,4BAA2B;AAC3B,8EAA+F;AAC/F,mCAAkC;AAElC,MAAa,cAAc;IAA3B;QACmB,SAAI,GAAmB,IAAI,GAAG,EAAE,CAAA;QAChC,eAAU,GAAqB,IAAI,sCAAmB,CAAC,kBAAgB,CAAC,CAAA;IAyD3F,CAAC;IAvDC,YAAY,CAAC,GAAM;QACjB,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACzD,IAAI,GAAG,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,EAAE,kBAAkB,CAAC,CAAA;QACvF,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAChC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QAC9B,OAAO,CAAC,CAAC,SAAS,CAAC,OAA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CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAA;YAC1D,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;SAC9B;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE;YACvB,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;YACvB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;SAC5B;QACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1D,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACvD,CAAC;IAEO,OAAO,CAAC,GAAuB;QACrC,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAA;QACpD,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjD,OAAO,GAAG,aAAa,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAA;IAC/D,CAAC;CACF;AA3DD,wCA2DC","sourcesContent":["import * as _ from 'lodash'\nimport { CryptoPrimitives, WebCryptoPrimitives } from '../../icc-x-api/crypto/CryptoPrimitives'\nimport { webcrypto } from 'crypto'\n\nexport class FakeGenericApi<T extends { id?: string; rev?: string }> {\n private readonly data: Map<string, T> = new Map()\n private readonly primitives: CryptoPrimitives = new WebCryptoPrimitives(webcrypto as any)\n\n createObject(obj: T): T {\n if (!obj.id) throw new Error(`New object should have id`)\n if (obj.rev) throw new Error(`New object should not have rev`)\n if (this.data.get(obj.id!)) throw new Error(`Object with id ${obj.id} already exists.`)\n const withRev = _.cloneDeep(obj)\n withRev.rev = this.nextRev(withRev.rev)\n this.data.set(obj.id, withRev)\n return _.cloneDeep(withRev)\n }\n\n modifyObject(obj: T): T {\n if (!obj.id) throw new Error(`Modified object should have id`)\n const existing = this.data.get(obj.id!)\n if (!existing) throw new Error(`No object with id ${obj.id}`)\n if (existing.rev !== obj.rev) throw new Error(`Object with id ${obj.id} has wrong rev: ${obj.rev} but expected ${existing.rev}.`)\n const withNewRev = _.cloneDeep(obj)\n withNewRev.rev = this.nextRev(withNewRev.rev)\n this.data.set(obj.id, withNewRev)\n return _.cloneDeep(withNewRev)\n }\n\n getAll(): T[] {\n return [...this.data.values()].map((x) => _.cloneDeep(x))\n }\n\n getPaged(\n startId: string | undefined,\n limit: number\n ): {\n rows: T[]\n nextId: string | undefined\n } {\n let rows = [...this.data.values()]\n let nextId = undefined\n if (startId) {\n const startIndex = rows.findIndex((x) => x.id === startId)\n rows = rows.slice(startIndex)\n }\n if (rows.length > limit) {\n nextId = rows[limit].id\n rows = rows.slice(0, limit)\n }\n return { rows: rows.map((x) => _.cloneDeep(x)), nextId }\n }\n\n getById(id: string): T | undefined {\n const retrieved = this.data.get(id)\n return retrieved ? _.cloneDeep(retrieved) : undefined\n }\n\n private nextRev(rev: string | undefined): string {\n if (!rev) return `1-${this.primitives.randomUuid()}`\n const prevRevNumber = parseInt(rev.split('-')[0])\n return `${prevRevNumber + 1}-${this.primitives.randomUuid()}`\n }\n}\n"]}
|