@icure/cardinal-sdk 3.0.0-PREVIEW-2 → 3.0.0-PREVIEW-3

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.
@@ -2,6 +2,7 @@ import { EntityWithEncryptionMetadataTypeName } from '../crypto/entities/EntityW
2
2
  import { ExchangeDataInjectionDetails } from '../crypto/entities/ExchangeDataInjectionDetails.mjs';
3
3
  import { RawDecryptedExchangeData } from '../crypto/entities/RawDecryptedExchangeData.mjs';
4
4
  import { Pkcs8Bytes } from '../model/specializations/Pkcs8Bytes.mjs';
5
+ import { SpkiHexString } from '../model/specializations/SpkiHexString.mjs';
5
6
  import { CryptoInGroupApi } from './CryptoInGroupApi.mjs';
6
7
  import { ShamirKeysManagerApi } from './ShamirKeysManagerApi.mjs';
7
8
  /**
@@ -57,4 +58,26 @@ export interface CryptoApi {
57
58
  * having to re-inject it (as long as the instance has access to the current private key).
58
59
  */
59
60
  injectExchangeData(groupId: string | undefined, details: Array<ExchangeDataInjectionDetails>, reEncryptWithOwnKeys: boolean): Promise<void>;
61
+ /**
62
+ *
63
+ * Make sure that a data owner that is a member of the same simple-type group as the current data owner has access
64
+ * to all the exchange data of that group.
65
+ *
66
+ * [sharedSimpleDataOwnerGroupId] must be a simple-type data owner group, of the same data-owner-type as the current
67
+ * delegator actor, and both the current delegator actor data owner and the [delegate] data owner must be directly
68
+ * or indirectly through transitive links members of the [sharedSimpleDataOwnerGroupId] group; if they are not this
69
+ * method fails with a [IllegalArgumentException] without applying any change to the exchange data.
70
+ *
71
+ * If [delegatePublicKey] is null this method will simply check that for each exchange data of the group there is
72
+ * also a piece for the [delegate] data owner. If [delegatePublicKey] is not null this method will also check that
73
+ * the piece for the [delegate] data owner contains entries for the provided public key.
74
+ *
75
+ * This method returns true if all exchange data that was found for [sharedSimpleDataOwnerGroupId] could be
76
+ * successfully reshared with the [delegate] data owner, false if some data could not be shared (failed to update
77
+ * it, or there is no piece that the current sdk could decrypt); this method will do its best effort to share as
78
+ * much as possible (does not stop on the first failure)
79
+ */
80
+ ensureHasAccessToSharedSimpleDataOwnerGroupExchangeData(delegate: string, sharedSimpleDataOwnerGroupId: string, options?: {
81
+ delegatePublicKey?: SpkiHexString | undefined;
82
+ }): Promise<boolean>;
60
83
  }
@@ -33,9 +33,17 @@ export interface DataOwnerApi {
33
33
  /**
34
34
  *
35
35
  * If the logged user is a data owner get its data owner groups hierarchy (all types).
36
+ * This method result is cached
36
37
  * @return the current user's data owner hierarchy tree, starting from the user itself
37
38
  */
38
39
  getCurrentDataOwnerHierarchyInfo(): Promise<DataOwnerHierarchyInfo>;
40
+ /**
41
+ *
42
+ * Get the hierarchy information for a data owner.
43
+ * If [dataOwnerId] is the current data owener this method is equivalent to [getCurrentDataOwnerHierarchyInfo],
44
+ * except it does not use cached information.
45
+ */
46
+ getDataOwnerHierarchyInfo(dataOwnerId: string): Promise<DataOwnerHierarchyInfo>;
39
47
  /**
40
48
  *
41
49
  * Get a data owner regardless of its actual type. The logged user must have the permission to access the data
@@ -114,4 +122,103 @@ export interface DataOwnerApi {
114
122
  [key: string]: RsaEncryptionAlgorithm;
115
123
  };
116
124
  }>;
125
+ /**
126
+ *
127
+ * Add data owners to a data owner group.
128
+ * The data owners must all be of the same type (as indicated by [dataOwnerType]).
129
+ * The data owner group (indicated by [dataOwnerGroupId]) must exist, or this method will fail; if any of the data
130
+ * owners in [newMembersIds] does not exist, or they can't be updated (for example, if there are too many concurrent
131
+ * changes to that data owner) or can't be added to the group (because of restrictions on group link type), they
132
+ * will be ignored.
133
+ *
134
+ * The result contains the ids of all the data owners that were successfully added, or that were already members of
135
+ * the group.
136
+ *
137
+ * There is no guarantee on order of returned elements.
138
+ *
139
+ * Only the links that a data owner declares directly are considered: a data owner that is already a member of
140
+ * [dataOwnerGroupId] transitively, through another group it is linked to, has no link of its own to it and is
141
+ * therefore linked to it directly, exactly like any other new member.
142
+ *
143
+ * Soft-deleted data owners are not ignored: they are updated and returned like any other member. A soft-deleted
144
+ * data owner can be undeleted at any moment, and it should then have the group membership it was given in the
145
+ * meantime.
146
+ *
147
+ * # Interruption and retry
148
+ *
149
+ * This method is idempotent: adding a data owner that is already a member is a no-op that still reports the data
150
+ * owner as added. If a call terminates early some of the members may have been added and the result gives no
151
+ * indication of which: calling the method again with the same input picks up exactly the work that is left, and
152
+ * repeating it eventually adds every member that can be added.
153
+ */
154
+ addDataOwnersToGroup(dataOwnerType: DataOwnerType, dataOwnerGroupId: string, newMembersIds: Array<string>): Promise<Array<string>>;
155
+ /**
156
+ *
157
+ * Remove data owners from a data owner group.
158
+ * The data owners must all be of the same type (as indicated by [dataOwnerType]).
159
+ * The data owner group (indicated by [dataOwnerGroupId]) must exist, or this method will fail; if any of the data
160
+ * owners in [membersToRemoveIds] does not exist, or they can't be updated (for example if there are too many
161
+ * concurrent changes to that data owner), they will be ignored.
162
+ * The result contains the ids of all the data owners that were successfully removed, or that were already not
163
+ * members of the group.
164
+ *
165
+ * Before returning this method will check if there is exchange data that should be invalidated for encryption as a
166
+ * result of the removal of [membersToRemoveIds] from [dataOwnerGroupId]:
167
+ * 1. Invalidation is performed only if [dataOwnerGroupId] represents a simple-type group. If [dataOwnerGroupId]
168
+ * represents a parent-type group then no invalidation will be performed (invalidation must be performed at the
169
+ * level of the group keypair, not at the level of the exchange data).
170
+ * 2. The exchange data considered for invalidation is all exchange data where [dataOwnerGroupId] is one of the
171
+ * members. If the data owner group itself has links to other groups, then also exchange data where one of those
172
+ * groups is a member will be considered, transitively (following only simple-type links, the only kind a
173
+ * simple-type group may declare).
174
+ * 3. Of the removed members, only the ones this removal actually cut off from the group whose exchange data is
175
+ * being considered are taken into account, and that is decided for each of the groups of step 2 separately. A
176
+ * data owner that is still a member of that group once the links it declared itself are gone — because it
177
+ * belongs to another group that is itself a member of it — keeps its access to that exchange data
178
+ * legitimately, so nothing of it is invalidated on its behalf: that would only force the exchange data of
179
+ * everyone else to be recreated for nothing. This covers a member that declared several paths to a group and
180
+ * lost only one, a member that was only ever linked to it transitively and therefore had nothing to lose, and
181
+ * a member that lost [dataOwnerGroupId] but belongs to one of the groups above it in its own right. If no
182
+ * member is left for any of the groups of step 2, no exchange data is invalidated at all.
183
+ * 4. If any of the members cut off from one of the groups of step 2 is itself a simple-type data owner-group then
184
+ * all the exchange data of that group is invalidated; otherwise only its exchange data where there is at least
185
+ * a piece for a recipient that is one of the members cut off from it
186
+ *
187
+ * Only the links a data owner declares itself are considered and removed: a data owner that is a member of
188
+ * [dataOwnerGroupId] transitively, through another group it is linked to, has no link of its own to remove, so it
189
+ * is treated — and reported — as removed while it keeps that transitive membership. A transitive membership can
190
+ * only be changed where the link that creates it is declared: by removing the data owner from the intermediate
191
+ * group, or by removing the intermediate group from [dataOwnerGroupId]. Such a data owner is reported as removed,
192
+ * but the invalidation above does not treat it as one (step 3): it is still a member, so the exchange data it can
193
+ * decrypt is left usable for encryption.
194
+ *
195
+ * Soft-deleted data owners are not ignored: they are updated and returned like any other member, and their
196
+ * exchange data pieces are considered for invalidation. A soft-deleted data owner can be undeleted at any moment,
197
+ * so leaving it in a group it was removed from, or leaving the exchange data it can decrypt usable for
198
+ * encryption, would be unsafe.
199
+ *
200
+ * # Interruption and retry
201
+ *
202
+ * This method is idempotent: removing a data owner that is not a member is a no-op that still reports the data
203
+ * owner as removed, and invalidating exchange data that is already invalidated is a no-op as well.
204
+ *
205
+ * The members are updated first and the exchange data is invalidated after, so a call that terminates early —
206
+ * the caller cancels it, some members could not be updated, or the invalidation itself fails, which is reported
207
+ * as an error after the members have already been removed — can leave members removed while the exchange data
208
+ * they can still decrypt is usable for encryption. Calling the method again with the same input picks up exactly
209
+ * the work that is left, and repeating it eventually removes every member that can be removed and invalidates
210
+ * everything that has to be invalidated; a caller that gets an error, or that does not receive every id it asked
211
+ * for, should retry until it does.
212
+ *
213
+ * The retry must use the same input, and not only the members missing from the result: a member that an
214
+ * interrupted call already removed is no longer a member of the group, so it still counts as cut off for the
215
+ * invalidation (which is why it is part of the result), and dropping it from the input would drop the exchange
216
+ * data that has a piece for it from the invalidation, leaving that exchange data usable for encryption.
217
+ *
218
+ * Note that any new exchange data created between two calls to this method will be considered for invalidation. If
219
+ * the new exchange data does not have entries for any of the removed recipients then it will be untouched, unless
220
+ * one of the removed recipients is a simple-type group, in which case also the new exchange data will be
221
+ * invalidated.
222
+ */
223
+ removeDataOwnersFromGroup(dataOwnerType: DataOwnerType, dataOwnerGroupId: string, membersToRemoveIds: Array<string>): Promise<Array<string>>;
117
224
  }
@@ -124,6 +124,16 @@ export interface HealthcarePartyApi {
124
124
  * up-to-date), then those entities will not be restored and will not appear in this list.
125
125
  */
126
126
  undeleteHealthcareParties(healthcareParties: Array<HealthcareParty>): Promise<Array<HealthcareParty>>;
127
+ /**
128
+ *
129
+ * Equivalent to [DataOwnerApi.addDataOwnersToGroup] but for healthcareParties.
130
+ */
131
+ addHealthcarePartiesToGroup(healthcarePartyGroup: HealthcareParty, healthcarePartiesToAdd: Array<HealthcareParty>): Promise<Array<string>>;
132
+ /**
133
+ *
134
+ * Equivalent to [DataOwnerApi.removeDataOwnersFromGroup] but for healthcareParties.
135
+ */
136
+ removeDataOwnersFromGroup(healthcarePartyGroup: HealthcareParty, healthcarePartiesToRemove: Array<HealthcareParty>): Promise<Array<string>>;
127
137
  /**
128
138
  *
129
139
  * Subscribe to receive real-time notifications when an entity is updated.