Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authenticated media endpoints #369

Closed
wants to merge 154 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
f10d39f
Update ownership metadata
AndrewFerr Dec 8, 2022
5d62511
Query & claim needed keys before encrypting (#270)
AndrewFerr Dec 8, 2022
6e9c700
Handle pre-shared invite keys (#271)
AndrewFerr Dec 8, 2022
367cdb9
Merge branch 'main' into element-main
AndrewFerr Dec 19, 2022
b505f75
Allow zero values for LRU config options
Half-Shot Jan 18, 2023
68c4733
Allow zero values for LRU config options (#6)
Half-Shot Jan 19, 2023
591b66e
Merge branch 'main' into travis/update
turt2live Mar 24, 2023
cbcc8ef
Update main branch to current v0.6.5 pre-release state (#7)
turt2live Mar 27, 2023
3900fe2
v0.6.4-element.0
Half-Shot Mar 28, 2023
9c2036c
Use the new members array?
turt2live Mar 28, 2023
2485ea1
Use the new members array? (#8)
Half-Shot Mar 28, 2023
b19bd4c
Fix key query and claim APIs to support async functionality (#314)
turt2live Apr 5, 2023
33c7242
Better interface
turt2live Apr 6, 2023
db33128
Fix key query and claim APIs to support async functionality (#9)
Half-Shot Apr 6, 2023
aa7394c
0.6.5
Half-Shot Apr 6, 2023
3bd23c4
Allow usage of the SQLite-based crypto store
AndrewFerr Apr 14, 2023
c73cacf
Add types for lowdb
AndrewFerr Apr 14, 2023
bce5d60
Update tests
AndrewFerr Apr 14, 2023
00a0b27
Update examples
AndrewFerr Apr 17, 2023
dc8202a
Fix lint rules for new the imports in examples
AndrewFerr Apr 17, 2023
4c07639
Test the SQLite crypto store
AndrewFerr Apr 20, 2023
3f24fb5
Fix lint rules
AndrewFerr Apr 20, 2023
a983376
Add missing semicolon
AndrewFerr Apr 20, 2023
50460ae
Merge branch 'sql-crypto-store'
AndrewFerr Apr 21, 2023
d4c8886
Reset version back to "develop" for jsdoc, for now
AndrewFerr Apr 21, 2023
5b75a2f
Support node 20, drop node 16
AndrewFerr Apr 25, 2023
82c0f14
Update deps
AndrewFerr Apr 25, 2023
18875a2
Update eslint
AndrewFerr Apr 25, 2023
563d129
Remove superfluous comment
AndrewFerr Apr 26, 2023
5f527b7
Support node 20, drop node 16 (#12)
AndrewFerr Apr 26, 2023
795323d
Update Jest
AndrewFerr Apr 26, 2023
11f3962
Update rust-sdk crypto dependency (#14)
AndrewFerr Apr 26, 2023
f62a508
Sync with upstream
AndrewFerr May 18, 2023
888c97d
Shortcircuit sync loop if we've requested to stop syncing
Half-Shot Jun 5, 2023
9df413e
Reduce our reliance on an up-to-date joined rooms cache (#16)
tadzik Jun 5, 2023
7902671
Update src/MatrixClient.ts
Half-Shot Jun 29, 2023
5617a1f
Refactor transaction handler.
Half-Shot Jun 29, 2023
fbec61f
Add scripts to aid PRs & releases (#18)
AndrewFerr Jun 29, 2023
6b37f16
Shortcircuit sync loop if we've requested to stop syncing (#19)
AndrewFerr Jun 29, 2023
813cc80
Correct the output folder for the Docs workflow (#21)
AndrewFerr Jun 29, 2023
f985cd4
Use remote default branches in helper scripts
AndrewFerr Jun 29, 2023
a0c209e
Fix races
Half-Shot Jul 3, 2023
cfae65f
Refactor transaction handler. (#20)
Half-Shot Jul 3, 2023
6cfd717
Upstream intake: dependency updates
AndrewFerr Jul 19, 2023
8c7c2ae
Remove Sled crypto store, use SQLite by default
AndrewFerr Jul 13, 2023
8e306a8
Remove Sled crypto store from examples & tests
AndrewFerr Jul 17, 2023
6eb9572
Fix operator precedence & typings
AndrewFerr Jul 18, 2023
73a38c1
Update rust-sdk bindings
AndrewFerr Aug 1, 2023
fef0d54
Pull to-device event list out of returned tuple
AndrewFerr Jul 19, 2023
974771b
Log when OlmMachine returns unexpected value
AndrewFerr Jul 19, 2023
d87f7d8
Add crypto test for to-device messages
AndrewFerr Aug 2, 2023
ceae460
Add support for key backups
AndrewFerr Jul 7, 2023
bfe6c37
Back up keys when receiving/creating them
AndrewFerr Jul 19, 2023
64463f4
Handle immediate outgoing backup requests
AndrewFerr Jul 25, 2023
e735cb5
Queue async key backup operations
AndrewFerr Aug 3, 2023
7449440
Fix/document awaits
AndrewFerr Aug 4, 2023
cc221fb
Apply review recommendations
AndrewFerr Aug 4, 2023
ae61b8f
Put auth_data signature in correct place
AndrewFerr Aug 4, 2023
bcee62b
Add key backup test
AndrewFerr Aug 4, 2023
1af9ee9
Satisfy linter
AndrewFerr Aug 4, 2023
f96ac19
Add tests and fixes
AndrewFerr Aug 10, 2023
746e4a7
Error when enabling backups with unknown algorithm
AndrewFerr Aug 10, 2023
a1d7a72
Merge branch 'af/no-sled'
AndrewFerr Aug 10, 2023
d6a8ff6
Merge branch 'af/to-device-msgs-fix'
AndrewFerr Aug 10, 2023
9a3dfae
Merge branch 'af/key-backups'
AndrewFerr Aug 10, 2023
c249cf5
Tweak key backup auth data type to fix docs
AndrewFerr Aug 11, 2023
401ad7a
Merge branch 'af/key-backups'
AndrewFerr Aug 11, 2023
ac1fe44
Get type checking from OlmMachine.shareRoomKey
AndrewFerr Aug 10, 2023
b3475a1
Merge branch 'main'
AndrewFerr Aug 11, 2023
2e00af9
Merge branch 'af/to-device-request-use-object'
AndrewFerr Aug 11, 2023
de0872d
Add support for exportRoomKeysForSession
Half-Shot Sep 4, 2023
187363e
Update dependency
Half-Shot Sep 6, 2023
3988fd3
Nitpick: fix inconsistent indent in package.json
AndrewFerr Sep 6, 2023
7fdb6e2
Rename & refactor session data export type
AndrewFerr Sep 6, 2023
b945461
Satisfy linter with trailing newline
AndrewFerr Sep 6, 2023
4b59dc0
Catch when CryptoClient can't find room members
AndrewFerr Sep 6, 2023
b5fbd7f
Put exportRoomKeysForSession on MatrixClient
AndrewFerr Sep 6, 2023
bd9fa96
Test room key exports
AndrewFerr Sep 6, 2023
ee77957
Emit an event when an Intent is created
AndrewFerr Sep 6, 2023
dab204a
Warn instead of error
AndrewFerr Sep 6, 2023
8fbe5e0
Don't print error object in warning
AndrewFerr Sep 6, 2023
8dab018
Prevent setting multiple room key backup listeners
AndrewFerr Sep 6, 2023
356954e
Merge branch 'af/catch-crypto-room-event-member-lookup'
AndrewFerr Sep 7, 2023
e57073c
Merge branch 'af/listen-for-intent-setup'
AndrewFerr Sep 7, 2023
f03e778
Emit "intent.new" after caching the new Intent
AndrewFerr Sep 27, 2023
a5dcf62
Add test
AndrewFerr Sep 27, 2023
0c074f2
Merge branch 'af/listen-for-intent-setup'
AndrewFerr Sep 27, 2023
fb00ab4
Merge upstream dependency upgrades
AndrewFerr Oct 31, 2023
ea8c166
Merge upstream release
AndrewFerr Nov 17, 2023
686a499
Add getEventNearestToTimestamp
Half-Shot Nov 22, 2023
9c6835e
Add tests for getEventNearestToTimestamp
Half-Shot Nov 22, 2023
06e66df
v1
Half-Shot Nov 22, 2023
cf05059
Fix test
Half-Shot Nov 23, 2023
703e625
Fix tests
Half-Shot Nov 23, 2023
669408d
Add getEventNearestToTimestamp (#38)
AndrewFerr Nov 24, 2023
471842d
Batch tracked users setup
Half-Shot Nov 24, 2023
a8a9242
Ensure we cache a room when it's not encrypted.
Half-Shot Nov 24, 2023
2fdc594
Cache rooms that are not encrypted.
Half-Shot Nov 24, 2023
0ee885e
Recheck encrypted status on each m.room.encryption
Half-Shot Nov 24, 2023
b924ef0
Don't check all joined rooms on startup
Half-Shot Nov 24, 2023
5c059a1
Fix test
Half-Shot Nov 24, 2023
bf1159e
Fix tests
Half-Shot Nov 27, 2023
be459b0
Comma
Half-Shot Nov 27, 2023
e84fee9
Rewrite logic to determine correct client to decrypt event/.
Half-Shot Nov 28, 2023
42fc7e8
Use ES2022 for Error causes
Half-Shot Nov 28, 2023
ed4ba92
Fix release version
Half-Shot Nov 28, 2023
15643f8
And examples too
Half-Shot Nov 28, 2023
81e6824
Fix obvious bs
Half-Shot Nov 29, 2023
7e050c7
Fix branch
Half-Shot Nov 29, 2023
da2792e
Cache non-encrypted rooms and skip fetching encrypted rooms on startu…
Half-Shot Dec 4, 2023
f656aba
Save an iteration
Half-Shot Dec 4, 2023
e95019d
Add new
Half-Shot Dec 4, 2023
5a0dd1e
Ensure we check if the room is encrypted first.
Half-Shot Dec 4, 2023
c852f25
Tidy up
Half-Shot Dec 4, 2023
a806668
Batch tracked users setup (#40)
Half-Shot Dec 4, 2023
9344147
Lint
Half-Shot Dec 4, 2023
545eb16
Use a more structured algorithm for determining decryption client for…
Half-Shot Dec 4, 2023
db39b0a
0.7.0
Half-Shot Dec 4, 2023
124a70c
Allow specifing a specific device ID for impersonation.
Half-Shot Dec 19, 2023
6ab2f49
Warn if the device changes./
Half-Shot Dec 19, 2023
9014b6b
Clear storage if the device changes.
Half-Shot Dec 19, 2023
277d3d8
Cleanup
Half-Shot Dec 19, 2023
78d48dc
Lint
Half-Shot Dec 19, 2023
e25be55
Warn properly
Half-Shot Dec 19, 2023
e5dcc5a
Make tests happy
Half-Shot Dec 19, 2023
34f8695
Tidy more
Half-Shot Dec 19, 2023
959e603
Fix another test
Half-Shot Dec 19, 2023
3d82d83
Refactor to instead create a new storage per device, rather than dele…
Half-Shot Dec 20, 2023
5672a5a
Log the migration
Half-Shot Dec 20, 2023
1c031ef
Move all files but allow it to fail
Half-Shot Dec 20, 2023
583b1cd
trailing commas
Half-Shot Dec 20, 2023
cbf2d45
Allow setting a specific impersonation device for appservices (#43)
Half-Shot Dec 20, 2023
28a69be
Update epxress to 4.17.21
Half-Shot Jan 5, 2024
49a9f30
Merge branch 'hs/update-express-4.17.21'
Half-Shot Jan 5, 2024
9e74b79
0.7.0-element.0
Half-Shot Jan 5, 2024
3a0fa26
Fix error
Half-Shot Jan 23, 2024
0ff14e9
update package.json
Half-Shot Feb 9, 2024
a98ae4f
Update matrix-sdk-crypto-nodejs to 0.2.0-beta.1
Half-Shot Jun 11, 2024
724e203
Adjust URLs for backup test and timeouts
Half-Shot Jun 11, 2024
34b96a7
drop packageManager
Half-Shot Jun 12, 2024
ce8f9ca
Update matrix-sdk-crypto-nodejs to 0.2.0-beta.1 (#44)
Half-Shot Jun 13, 2024
c944bf4
Add Retry-After header parsing.
Half-Shot Mar 20, 2024
9380c2b
Add comprehensive tests.
Half-Shot Mar 20, 2024
213846a
Merge remote-tracking branch 't2/main'
Half-Shot Jun 13, 2024
9bfc71f
Add packageManager declaration
Half-Shot Jun 13, 2024
e4e7e65
v0.7.1-element.0
Half-Shot Jun 13, 2024
816d1a3
0.7.1-element.1
Half-Shot Jul 8, 2024
798f2d3
Add support for some content scanner endpoints. (#45)
Half-Shot Jul 11, 2024
634acd6
Add option to view/edit locked state of users (#47)
Half-Shot Jul 29, 2024
8e2d32d
Passthrough scanner config to appservice intents.
Half-Shot Jul 15, 2024
6b780ee
0.7.1-element.2
Half-Shot Jul 15, 2024
aadd228
0.7.1-element.3
Half-Shot Jul 15, 2024
b3d2d64
0.7.1-element.4
Half-Shot Jul 29, 2024
f1d25a9
Support authenticated media endpoints.
Half-Shot Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions src/appservice/Appservice.ts
Original file line number Diff line number Diff line change
@@ -958,16 +958,22 @@ export class Appservice extends EventEmitter {
}

let responded = false;
this.emit("query.key_claim", req.body, async (result: MSC3983KeyClaimResponse | Promise<MSC3983KeyClaimResponse> | undefined | null) => {
if (result?.then) result = await result;
if (!result) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });
responded = true;
return;
}

res.status(200).json(result);
this.emit("query.key_claim", req.body, (result: MSC3983KeyClaimResponse | Promise<MSC3983KeyClaimResponse> | undefined | null) => {
responded = true;

const handleResult = (result2: MSC3983KeyClaimResponse) => {
if (!result2) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });
return;
}

res.status(200).json(result2);
};

Promise.resolve(result).then(r => handleResult(r)).catch(e => {
LogService.error("Appservice", "Error handling key claim API", e);
res.status(500).json({ errcode: "M_UNKNOWN", error: "Error handling key claim API" });
});
});
if (!responded) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });
@@ -986,18 +992,24 @@ export class Appservice extends EventEmitter {
}

let responded = false;
this.emit("query.key", req.body, async (result: MSC3984KeyQueryResponse | Promise<MSC3984KeyQueryResponse> | undefined | null) => {
if ((result as any)?.then) result = await result;
if (!result) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });
responded = true;
return;
}
this.emit("query.key", req.body, (result: MSC3984KeyQueryResponse | Promise<MSC3984KeyQueryResponse> | undefined | null) => {
responded = true;

// Implementation note: we could probably query the device keys from our storage if we wanted to.
const handleResult = (result2: MSC3984KeyQueryResponse) => {
if (!result2) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });
return;
}

res.status(200).json(result);
responded = true;
// Implementation note: we could probably query the device keys from our storage if we wanted to.

res.status(200).json(result2);
};

Promise.resolve(result).then(r => handleResult(r)).catch(e => {
LogService.error("Appservice", "Error handling key query API", e);
res.status(500).json({ errcode: "M_UNKNOWN", error: "Error handling key query API" });
});
});
if (!responded) {
res.status(404).json({ errcode: "M_UNRECOGNIZED", error: "Endpoint not implemented" });