File tree Expand file tree Collapse file tree 4 files changed +37
-29
lines changed
crypto-ffi/bindings/js/test Expand file tree Collapse file tree 4 files changed +37
-29
lines changed Original file line number Diff line number Diff line change @@ -153,11 +153,15 @@ export async function invite(
153153 cc2 : CoreCrypto ,
154154 conversationId : ConversationId
155155) : Promise < GroupInfoBundle > {
156- const [ kp ] = await cc2 . transaction ( ( ctx ) =>
157- ctx . clientKeypackages ( DEFAULT_CIPHERSUITE , CredentialType . Basic , 1 )
158- ) ;
156+ const kp = await cc2 . transaction ( async ( ctx ) => {
157+ const [ credentialRef ] = await ctx . findCredentials ( {
158+ ciphersuite : DEFAULT_CIPHERSUITE ,
159+ credentialType : CredentialType . Basic ,
160+ } ) ;
161+ return await ctx . generateKeypackage ( credentialRef ! ) ;
162+ } ) ;
159163 await cc1 . transaction ( ( ctx ) =>
160- ctx . addClientsToConversation ( conversationId , [ kp ! ] )
164+ ctx . addClientsToConversation ( conversationId , [ kp . serialize ( ) ] )
161165 ) ;
162166 const { groupInfo, welcome } =
163167 await DELIVERY_SERVICE . getLatestCommitBundle ( ) ;
Original file line number Diff line number Diff line change @@ -26,21 +26,26 @@ describe("client identity", () => {
2626 expect ( result ) . toBe ( 32 ) ;
2727 } ) ;
2828
29- it ( "requesting client key packages should work" , async ( ) => {
29+ it ( "requesting client key package should work" , async ( ) => {
3030 const alice = crypto . randomUUID ( ) ;
3131 await ccInit ( alice ) ;
32- const result = await browser . execute ( async ( clientName ) => {
32+ const error = await browser . execute ( async ( clientName ) => {
3333 const cc = window . ensureCcDefined ( clientName ) ;
34- return (
35- await cc . transaction ( async ( ctx ) => {
36- return await ctx . clientKeypackages (
37- window . defaultCipherSuite ,
38- window . ccModule . CredentialType . Basic ,
39- 20 // Count of requested key packages
40- ) ;
41- } )
42- ) . length ;
34+ let error = false ;
35+ try {
36+ const keypackage = await cc . transaction ( async ( ctx ) => {
37+ const [ credentialRef ] = await ctx . findCredentials ( {
38+ ciphersuite : window . defaultCipherSuite ,
39+ credentialType : window . ccModule . CredentialType . Basic ,
40+ } ) ;
41+ return await ctx . generateKeypackage ( credentialRef ! ) ;
42+ } ) ;
43+ keypackage . serialize ( ) ;
44+ } catch {
45+ error = true ;
46+ }
47+ return error ;
4348 } , alice ) ;
44- expect ( result ) . toBe ( 20 ) ;
49+ expect ( error ) . toBe ( false ) ;
4550 } ) ;
4651} ) ;
Original file line number Diff line number Diff line change @@ -53,11 +53,10 @@ describe("transaction context", () => {
5353 } ) ;
5454
5555 try {
56- await context ! . clientKeypackages (
57- window . defaultCipherSuite ,
58- window . ccModule . CredentialType . Basic ,
59- 1
60- ) ;
56+ await context ! . findCredentials ( {
57+ ciphersuite : window . defaultCipherSuite ,
58+ credentialType : window . ccModule . CredentialType . Basic ,
59+ } ) ;
6160 } catch ( err ) {
6261 const e = err as { context ?: { context ?: { msg ?: string } } } ;
6362 return {
Original file line number Diff line number Diff line change @@ -296,19 +296,19 @@ export async function invite(
296296 const cc1 = window . ensureCcDefined ( client1 ) ;
297297 const cc2 = window . ensureCcDefined ( client2 ) ;
298298
299- const [ kp ] = await cc2 . transaction ( ( ctx ) =>
300- ctx . clientKeypackages (
301- window . defaultCipherSuite ,
302- window . ccModule . CredentialType . Basic ,
303- 1
304- )
305- ) ;
299+ const kp = await cc2 . transaction ( async ( ctx ) => {
300+ const [ credentialRef ] = await ctx . findCredentials ( {
301+ ciphersuite : window . defaultCipherSuite ,
302+ credentialType : window . ccModule . CredentialType . Basic ,
303+ } ) ;
304+ return await ctx . generateKeypackage ( credentialRef ! ) ;
305+ } ) ;
306306
307307 const cid = new window . ccModule . ConversationId (
308308 new TextEncoder ( ) . encode ( conversationId ) . buffer
309309 ) ;
310310 await cc1 . transaction ( ( ctx ) =>
311- ctx . addClientsToConversation ( cid , [ kp ! ] )
311+ ctx . addClientsToConversation ( cid , [ kp . serialize ( ) ] )
312312 ) ;
313313 const commitBundle =
314314 await window . deliveryService . getLatestCommitBundle ( ) ;
You can’t perform that action at this time.
0 commit comments