1
- const { OlmMachine, UserId, DeviceId, RoomId, DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest } = require ( '../' ) ;
1
+ const { initTracing, OlmMachine, UserId, DeviceId, RoomId, DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest, EncryptionSettings } = require ( '../' ) ;
2
+
3
+ //initTracing();
2
4
3
5
describe ( OlmMachine . name , ( ) => {
4
6
test ( 'cannot be instantiated with the constructor' , ( ) => {
@@ -80,13 +82,14 @@ describe(OlmMachine.name, () => {
80
82
} ) ;
81
83
82
84
test ( 'can mark requests as sent' , async ( ) => {
83
- const m = await machine ( ) ;
85
+ const m = await machine ( new UserId ( '@alice:example.org' ) , new DeviceId ( 'DEVICEID' ) ) ;
86
+
84
87
const toDeviceEvents = JSON . stringify ( { } ) ;
85
88
const changedDevices = new DeviceLists ( ) ;
86
89
const oneTimeKeyCounts = { } ;
87
90
const unusedFallbackKeys = [ ] ;
88
91
89
- const receiveSyncChanges = JSON . parse ( await m . receiveSyncChanges ( toDeviceEvents , changedDevices , oneTimeKeyCounts , unusedFallbackKeys ) ) ;
92
+ const receiveSyncChanges = await m . receiveSyncChanges ( toDeviceEvents , changedDevices , oneTimeKeyCounts , unusedFallbackKeys ) ;
90
93
const outgoingRequests = await m . outgoingRequests ( ) ;
91
94
92
95
expect ( outgoingRequests ) . toHaveLength ( 2 ) ;
@@ -96,13 +99,13 @@ describe(OlmMachine.name, () => {
96
99
expect ( request ) . toBeInstanceOf ( KeysUploadRequest ) ;
97
100
98
101
// https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3keysupload
99
- const hypothetic_response = JSON . stringify ( {
102
+ const hypothetical_response = JSON . stringify ( {
100
103
"one_time_key_counts" : {
101
104
"curve25519" : 10 ,
102
105
"signed_curve25519" : 20
103
106
}
104
107
} ) ;
105
- const marked = await m . markRequestAsSent ( request . id , request . type , hypothetic_response ) ;
108
+ const marked = await m . markRequestAsSent ( request . id , request . type , hypothetical_response ) ;
106
109
expect ( marked ) . toStrictEqual ( true ) ;
107
110
}
108
111
@@ -111,77 +114,57 @@ describe(OlmMachine.name, () => {
111
114
expect ( request ) . toBeInstanceOf ( KeysQueryRequest ) ;
112
115
113
116
// https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3keysquery
114
- const hypothetic_response = JSON . stringify ( {
117
+ const hypothetical_response = JSON . stringify ( {
115
118
"device_keys" : {
116
- "@alice:example.com " : {
119
+ "@alice:example.org " : {
117
120
"JLAFKJWSCS" : {
118
121
"algorithms" : [
119
122
"m.olm.v1.curve25519-aes-sha2" ,
120
123
"m.megolm.v1.aes-sha2"
121
124
] ,
122
125
"device_id" : "JLAFKJWSCS" ,
123
126
"keys" : {
124
- "curve25519:JLAFKJWSCS" : "3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI " ,
125
- "ed25519:JLAFKJWSCS" : "lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI "
127
+ "curve25519:JLAFKJWSCS" : "wjLpTLRqbqBzLs63aYaEv2Boi6cFEbbM/sSRQ2oAKk4 " ,
128
+ "ed25519:JLAFKJWSCS" : "nE6W2fCblxDcOFmeEtCHNl8/l8bXcu7GKyAswA4r3mM "
126
129
} ,
127
130
"signatures" : {
128
- "@alice:example.com " : {
129
- "ed25519:JLAFKJWSCS" : "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA "
131
+ "@alice:example.org " : {
132
+ "ed25519:JLAFKJWSCS" : "m53Wkbh2HXkc3vFApZvCrfXcX3AI51GsDHustMhKwlv3TuOJMj4wistcOTM8q2+e/Ro7rWFUb9ZfnNbwptSUBA "
130
133
}
131
134
} ,
132
135
"unsigned" : {
133
136
"device_display_name" : "Alice's mobile phone"
134
137
} ,
135
- "user_id" : "@alice:example.com "
138
+ "user_id" : "@alice:example.org "
136
139
}
137
140
}
138
141
} ,
139
- "master_keys" : {
140
- "@alice:example.com" : {
141
- "keys" : {
142
- "ed25519:base64+master+public+key" : "base64+master+public+key"
143
- } ,
144
- "usage" : [
145
- "master"
146
- ] ,
147
- "user_id" : "@alice:example.com"
148
- }
149
- } ,
150
- "self_signing_keys" : {
151
- "@alice:example.com" : {
152
- "keys" : {
153
- "ed25519:base64+self+signing+public+key" : "base64+self+signing+master+public+key"
154
- } ,
155
- "signatures" : {
156
- "@alice:example.com" : {
157
- "ed25519:base64+master+public+key" : "signature+of+self+signing+key"
158
- }
159
- } ,
160
- "usage" : [
161
- "self_signing"
162
- ] ,
163
- "user_id" : "@alice:example.com"
164
- }
165
- } ,
166
- "user_signing_keys" : {
167
- "@alice:example.com" : {
168
- "keys" : {
169
- "ed25519:base64+user+signing+public+key" : "base64+user+signing+master+public+key"
170
- } ,
171
- "signatures" : {
172
- "@alice:example.com" : {
173
- "ed25519:base64+master+public+key" : "signature+of+user+signing+key"
174
- }
175
- } ,
176
- "usage" : [
177
- "user_signing"
178
- ] ,
179
- "user_id" : "@alice:example.com"
180
- }
181
- }
142
+ "failures" : { }
182
143
} ) ;
183
- const marked = await m . markRequestAsSent ( request . id , request . type , hypothetic_response ) ;
144
+ const marked = await m . markRequestAsSent ( request . id , request . type , hypothetical_response ) ;
184
145
expect ( marked ) . toStrictEqual ( true ) ;
146
+
147
+ console . log ( await m . getMissingSessions ( [ user ] ) ) ;
185
148
}
186
149
} ) ;
150
+
151
+ /*
152
+ test('can get missing sessions', async () => {
153
+ const m = await machine();
154
+
155
+ expect(await m.getMissingSessions([user])).toStrictEqual(null);
156
+ });
157
+
158
+ test('can update tracked users', async () => {
159
+ const m = await machine();
160
+
161
+ expect(await m.updateTrackedUsers([user])).toStrictEqual(undefined);
162
+ });
163
+
164
+ test('can share a room key', async () => {
165
+ const m = await machine();
166
+
167
+ console.log(await m.shareRoomKey(room, [new UserId('@bob :example.org')], new EncryptionSettings()));
168
+ });
169
+ */
187
170
} ) ;
0 commit comments