@@ -72,7 +72,8 @@ export class DefaultCipherSdkService implements CipherSdkService {
7272 . admin ( )
7373 . edit (
7474 sdkUpdateRequest ,
75- originalCipherView ?. toSdkCipherView ( ) || new CipherView ( ) . toSdkCipherView ( ) ,
75+ originalCipherView ?. toSdkCipherView ( sdkCiphersClient ) ||
76+ new CipherView ( ) . toSdkCipherView ( sdkCiphersClient ) ,
7677 ) ;
7778 } else {
7879 result = await sdkCiphersClient . edit ( sdkUpdateRequest ) ;
@@ -283,20 +284,18 @@ export class DefaultCipherSdkService implements CipherSdkService {
283284 throw new Error ( "SDK not available" ) ;
284285 }
285286 using ref = sdk . take ( ) ;
287+ const sdkCiphersClient = ref . value . vault ( ) . ciphers ( ) ;
286288
287- const sdkCipherView = cipherView . toSdkCipherView ( ) ;
289+ const sdkCipherView = cipherView . toSdkCipherView ( sdkCiphersClient ) ;
288290
289- const result = await ref . value
290- . vault ( )
291- . ciphers ( )
292- . share_cipher (
293- sdkCipherView ,
294- asUuid ( organizationId ) ,
295- collectionIds . map ( ( id ) => asUuid ( id ) ) ,
296- originalCipherView ?. toSdkCipherView ( ) ,
297- ) ;
298-
299- return CipherView . fromSdkCipherView ( result ) ;
291+ const result = await sdkCiphersClient . share_cipher (
292+ sdkCipherView ,
293+ asUuid ( organizationId ) ,
294+ collectionIds . map ( ( id ) => asUuid ( id ) ) ,
295+ originalCipherView ?. toSdkCipherView ( sdkCiphersClient ) ,
296+ ) ;
297+
298+ return CipherView . fromSdkCipherView ( result , sdkCiphersClient ) ;
300299 } ) ,
301300 catchError ( ( error : unknown ) => {
302301 this . logService . error ( `Failed to share cipher: ${ error } ` ) ;
@@ -319,20 +318,18 @@ export class DefaultCipherSdkService implements CipherSdkService {
319318 throw new Error ( "SDK not available" ) ;
320319 }
321320 using ref = sdk . take ( ) ;
321+ const sdkCiphersClient = ref . value . vault ( ) . ciphers ( ) ;
322322
323- const sdkCipherViews = cipherViews . map ( ( cv ) => cv . toSdkCipherView ( ) ) ;
323+ const sdkCipherViews = cipherViews . map ( ( cv ) => cv . toSdkCipherView ( sdkCiphersClient ) ) ;
324324
325- const results = await ref . value
326- . vault ( )
327- . ciphers ( )
328- . share_ciphers_bulk (
329- sdkCipherViews ,
330- asUuid ( organizationId ) ,
331- collectionIds . map ( ( id ) => asUuid ( id ) ) ,
332- ) ;
325+ const results = await sdkCiphersClient . share_ciphers_bulk (
326+ sdkCipherViews ,
327+ asUuid ( organizationId ) ,
328+ collectionIds . map ( ( id ) => asUuid ( id ) ) ,
329+ ) ;
333330
334331 return results
335- . map ( ( c ) => CipherView . fromSdkCipherView ( c ) )
332+ . map ( ( c ) => CipherView . fromSdkCipherView ( c , sdkCiphersClient ) )
336333 . filter ( ( c ) : c is CipherView => c !== undefined ) ;
337334 } ) ,
338335 catchError ( ( error : unknown ) => {
@@ -380,11 +377,14 @@ export class DefaultCipherSdkService implements CipherSdkService {
380377 throw new Error ( "SDK not available" ) ;
381378 }
382379 using ref = sdk . take ( ) ;
380+ const sdkCiphersClient = ref . value . vault ( ) . ciphers ( ) ;
383381
384- const decryptResult = await ref . value . vault ( ) . ciphers ( ) . get_all ( ) ;
382+ const decryptResult = await sdkCiphersClient . get_all ( ) ;
385383
386384 const successes = [ ...( decryptResult . successes ?? [ ] ) ]
387- . map ( ( sdkCipherView : any ) => CipherView . fromSdkCipherView ( sdkCipherView ) )
385+ . map ( ( sdkCipherView : any ) =>
386+ CipherView . fromSdkCipherView ( sdkCipherView , sdkCiphersClient ) ,
387+ )
388388 . filter ( ( v ) : v is CipherView => v !== undefined ) ;
389389
390390 const failures : CipherView [ ] = [ ...( decryptResult . failures ?? [ ] ) ] . map ( ( failure : any ) => {
@@ -449,15 +449,12 @@ export class DefaultCipherSdkService implements CipherSdkService {
449449 throw new Error ( "SDK not available" ) ;
450450 }
451451 using ref = sdk . take ( ) ;
452- const result = await ref . value
453- . vault ( )
454- . ciphers ( )
455- . admin ( )
456- . update_collection (
457- asUuid ( cipherId ) ,
458- collectionIds . map ( ( id ) => asUuid ( id ) ) ,
459- ) ;
460- return CipherView . fromSdkCipherView ( result ) ;
452+ const sdkCiphersClient = ref . value . vault ( ) . ciphers ( ) ;
453+ const result = await sdkCiphersClient . admin ( ) . update_collection (
454+ asUuid ( cipherId ) ,
455+ collectionIds . map ( ( id ) => asUuid ( id ) ) ,
456+ ) ;
457+ return CipherView . fromSdkCipherView ( result , sdkCiphersClient ) ;
461458 } ) ,
462459 catchError ( ( error : unknown ) => {
463460 this . logService . error ( `Failed to update cipher collections as admin: ${ error } ` ) ;
@@ -479,15 +476,13 @@ export class DefaultCipherSdkService implements CipherSdkService {
479476 throw new Error ( "SDK not available" ) ;
480477 }
481478 using ref = sdk . take ( ) ;
482- const result = await ref . value
483- . vault ( )
484- . ciphers ( )
485- . update_collection (
486- asUuid ( cipherId ) ,
487- collectionIds . map ( ( id ) => asUuid ( id ) ) ,
488- false ,
489- ) ;
490- return CipherView . fromSdkCipherView ( result ) ;
479+ const sdkCiphersClient = ref . value . vault ( ) . ciphers ( ) ;
480+ const result = await sdkCiphersClient . update_collection (
481+ asUuid ( cipherId ) ,
482+ collectionIds . map ( ( id ) => asUuid ( id ) ) ,
483+ false ,
484+ ) ;
485+ return CipherView . fromSdkCipherView ( result , sdkCiphersClient ) ;
491486 } ) ,
492487 catchError ( ( error : unknown ) => {
493488 this . logService . error ( `Failed to update cipher collections: ${ error } ` ) ;
0 commit comments