@@ -19,8 +19,8 @@ import "fake-indexeddb/auto";
19
19
import { IDBFactory } from "fake-indexeddb" ;
20
20
21
21
import { CRYPTO_BACKENDS , InitCrypto } from "../../test-utils/test-utils" ;
22
- import { createClient , MatrixClient } from "../../../src" ;
23
- import { bootstrapCrossSigning , mockSetupCrossSigningRequests } from "../../test-utils/cross-signing " ;
22
+ import { createClient , IAuthDict , MatrixClient } from "../../../src" ;
23
+ import { mockSetupCrossSigningRequests } from "../../test-utils/mockEndpoints " ;
24
24
25
25
afterEach ( ( ) => {
26
26
// reset fake-indexeddb after each test, to make sure we don't leak connections
@@ -62,13 +62,27 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
62
62
fetchMock . mockReset ( ) ;
63
63
} ) ;
64
64
65
+ /**
66
+ * Create cross-signing keys and publish the keys
67
+ *
68
+ * @param authDict - The parameters to as the `auth` dict in the key upload request.
69
+ * @see https://spec.matrix.org/v1.6/client-server-api/#authentication-types
70
+ */
71
+ async function bootstrapCrossSigning ( authDict : IAuthDict ) : Promise < void > {
72
+ // now bootstrap cross signing, and check it resolves successfully
73
+ await aliceClient . getCrypto ( ) ?. bootstrapCrossSigning ( {
74
+ // Expecting to return a promise
75
+ authUploadDeviceSigningKeys : ( makeRequest ) => makeRequest ( authDict ) . then ( ( ) => undefined ) ,
76
+ } ) ;
77
+ }
78
+
65
79
describe ( "bootstrapCrossSigning (before initialsync completes)" , ( ) => {
66
80
it ( "publishes keys if none were yet published" , async ( ) => {
67
81
mockSetupCrossSigningRequests ( ) ;
68
82
69
83
// provide a UIA callback, so that the cross-signing keys are uploaded
70
84
const authDict = { type : "test" } ;
71
- await bootstrapCrossSigning ( aliceClient , authDict ) ;
85
+ await bootstrapCrossSigning ( authDict ) ;
72
86
73
87
// check the cross-signing keys upload
74
88
expect ( fetchMock . called ( "upload-keys" ) ) . toBeTruthy ( ) ;
@@ -114,7 +128,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
114
128
115
129
// provide a UIA callback, so that the cross-signing keys are uploaded
116
130
const authDict = { type : "test" } ;
117
- await bootstrapCrossSigning ( aliceClient , authDict ) ;
131
+ await bootstrapCrossSigning ( authDict ) ;
118
132
119
133
const crossSigningStatus = await aliceClient . getCrypto ( ) ! . getCrossSigningStatus ( ) ;
120
134
@@ -138,7 +152,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("cross-signing (%s)", (backend: s
138
152
139
153
it ( "should return true after bootstrapping cross-signing" , async ( ) => {
140
154
mockSetupCrossSigningRequests ( ) ;
141
- await bootstrapCrossSigning ( aliceClient , { type : "test" } ) ;
155
+ await bootstrapCrossSigning ( { type : "test" } ) ;
142
156
143
157
const isCrossSigningReady = await aliceClient . getCrypto ( ) ! . isCrossSigningReady ( ) ;
144
158
0 commit comments