Compare commits

...

5 Commits

Author SHA1 Message Date
124c997fa3 fix(moxxy): Fix dependency compatibility with moxxmpp and Moxxy
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-09-29 18:47:38 +02:00
d02c2df160 release: Release 0.6.0
Some checks failed
ci/woodpecker/tag/woodpecker Pipeline failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-09-29 18:28:40 +02:00
1ffadcf583 fix: Update dependencies to run on Dart 3.5.1
Some checks failed
ci/woodpecker/manual/woodpecker Pipeline failed
2024-09-29 18:23:49 +02:00
c626629ade fix: Fix differences between example and newer versions
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-12-10 13:22:20 +01:00
ed6dcbee7a ci: Merge lint and test steps
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-10-08 00:10:45 +02:00
6 changed files with 64 additions and 50 deletions

View File

@ -1,16 +1,14 @@
pipeline: pipeline:
lint: analysis:
image: dart:3.0.7 image: dart:3.0.7
commands: commands:
# Proxy requests to pub.dev using pubcached # Proxy requests to pub.dev using pubcached
- PUB_HOSTED_URL=http://172.17.0.1:8000 dart pub get - PUB_HOSTED_URL=http://172.17.0.1:8000 dart pub get
- dart analyze --fatal-infos --fatal-warnings - dart analyze --fatal-infos --fatal-warnings
test:
image: dart:3.0.7
commands:
# Proxy requests to pub.dev using pubcached
- PUB_HOSTED_URL=http://172.17.0.1:8000 dart pub get
- dart test - dart test
when:
path:
includes: ['lib/**', 'test/**']
notify: notify:
image: git.polynom.me/papatutuwawa/woodpecker-xmpp image: git.polynom.me/papatutuwawa/woodpecker-xmpp
settings: settings:

View File

@ -70,4 +70,8 @@ This version is a complete rework of omemo_dart!
## 0.5.1 ## 0.5.1
- Remove `added` and `replaced` from the data passed to the `CommitRatchetsCallback` - Remove `added` and `replaced` from the data passed to the `CommitRatchetsCallback`
- Added a list of newly added and replaced ratchets to the encryption and decryption results. This is useful for displaying messages like "Contact added a new device" - Added a list of newly added and replaced ratchets to the encryption and decryption results. This is useful for displaying messages like "Contact added a new device"
## 0.6.0
- Bump dependencies to fix running with never version of Dart

View File

@ -17,7 +17,7 @@ void main() async {
// implements "Blind Trust Before Verification". To make things simpler, we keep // implements "Blind Trust Before Verification". To make things simpler, we keep
// no persistent data and can thus use the MemoryBTBVTrustManager. If we wanted to keep // no persistent data and can thus use the MemoryBTBVTrustManager. If we wanted to keep
// the state, we would have to override BlindTrustBeforeVerificationTrustManager. // the state, we would have to override BlindTrustBeforeVerificationTrustManager.
MemoryBTBVTrustManager(), BlindTrustBeforeVerificationTrustManager(),
// This function is called whenever we need to send an OMEMO heartbeat to [recipient]. // This function is called whenever we need to send an OMEMO heartbeat to [recipient].
// [result] is the encryted data to include. This needs to be wired into your XMPP library's // [result] is the encryted data to include. This needs to be wired into your XMPP library's
// OMEMO implementation. // OMEMO implementation.
@ -41,9 +41,7 @@ void main() async {
(device) async {}, (device) async {},
); );
// Alice now wants to chat with Bob at his bare Jid "bob@other.server". To make things // Bob, on his side, also creates an [OmemoManager] similar to Alice.
// simple, we just generate the identity bundle ourselves. In the real world, we would
// request it using PEP and then convert the device bundle into a OmemoBundle object.
final bobManager = OmemoManager( final bobManager = OmemoManager(
await OmemoDevice.generateNewDevice(bobJid), await OmemoDevice.generateNewDevice(bobJid),
BlindTrustBeforeVerificationTrustManager(), BlindTrustBeforeVerificationTrustManager(),
@ -51,10 +49,13 @@ void main() async {
(jid) async => [], (jid) async => [],
(jid, id) async => null, (jid, id) async => null,
(jid) async {}, (jid) async {},
(device) async {},
); );
// Alice prepares to send the message to Bob, so she builds the message stanza and // Alice prepares to send the message to Bob, so she builds the message stanza and
// collects all the children of the stanza that should be encrypted into a string. // collects all the children of the stanza that should be encrypted into a string.
// Note that this leaves out the wrapping stanza, i.e. if we want to send a <message />
// we only include the <message />'s children.
const aliceMessageStanzaBody = ''' const aliceMessageStanzaBody = '''
<body>Hello Bob, it's me, Alice!</body> <body>Hello Bob, it's me, Alice!</body>
<super-secret-element xmlns='super-secret-element' /> <super-secret-element xmlns='super-secret-element' />
@ -75,10 +76,10 @@ void main() async {
</envelope> </envelope>
'''; ''';
// Since Alice has no open session with Bob, we need to tell the session manager to build // Next, we encrypt the envelope element using Alice's [OmemoManager]. It will
// it when sending the message. // automatically attempt to fetch the device bundles of Bob.
final message = await aliceSession.onOutgoingStanza( final message = await aliceManager.onOutgoingStanza(
OmemoOutgoingStanza( const OmemoOutgoingStanza(
// The bare receiver Jid // The bare receiver Jid
[bobJid], [bobJid],
@ -87,17 +88,15 @@ void main() async {
), ),
); );
// In a proper implementation, we should also do some error checking here. // In a proper implementation, we would also do some error checking here.
// Alice now builds the actual message stanza for Bob // Alice now builds the actual message stanza for Bob
final payload = base64.encode(message.ciphertext!); final payload = base64.encode(message.ciphertext!);
final aliceDevice = await aliceSession.getDevice(); final aliceDevice = await aliceManager.getDevice();
// ignore: unused_local_variable
final bobDevice = await bobSession.getDevice();
// Since we know we have just one key for Bob, we take a shortcut. However, in the real // Since we know we have just one key for Bob, we take a shortcut. However, in the real
// world, we have to serialise every EncryptedKey to a <key /> element and group them // world, we have to serialise every EncryptedKey to a <key /> element and group them
// per Jid. // per Jid.
final key = message.encryptedKeys[0]; final key = message.encryptedKeys[bobJid]![0];
// Note that the key's "kex" attribute refers to key.kex. It just means that the // Note that the key's "kex" attribute refers to key.kex. It just means that the
// encrypted key also contains the required data for Bob to build a session with Alice. // encrypted key also contains the required data for Bob to build a session with Alice.
@ -107,7 +106,7 @@ void main() async {
<encrypted xmlns='urn:xmpp:omemo:2'> <encrypted xmlns='urn:xmpp:omemo:2'>
<header sid='${aliceDevice.id}'> <header sid='${aliceDevice.id}'>
<keys jid='$bobJid'> <keys jid='$bobJid'>
<key rid='${key.rid} kex='true'> <key rid='${key.rid} kex='${key.kex}'>
${key.value} ${key.value}
</key> </key>
</keys> </keys>
@ -125,7 +124,7 @@ void main() async {
// Bob now receives an OMEMO encrypted message from Alice and wants to decrypt it. // Bob now receives an OMEMO encrypted message from Alice and wants to decrypt it.
// Since we have just one key, let's just deserialise the one key by hand. // Since we have just one key, let's just deserialise the one key by hand.
final keys = [ final keys = [
EncryptedKey(bobJid, key.rid, key.value, true), EncryptedKey(key.rid, key.value, true),
]; ];
// Bob extracts the payload and attempts to decrypt it. // Bob extracts the payload and attempts to decrypt it.
@ -134,14 +133,9 @@ void main() async {
OmemoIncomingStanza( OmemoIncomingStanza(
// The bare sender JID of the message. In this case, it's Alice's. // The bare sender JID of the message. In this case, it's Alice's.
aliceJid, aliceJid,
// The 'sid' attribute of the <header /> element. Here, we know that Alice only has one device. // The 'sid' attribute of the <header /> element. Here, we know that Alice only has one device.
aliceDevice.id, aliceDevice.id,
// Time the message was sent. Since the message was not delayed, we use the
// current time.
DateTime.now().millisecondsSinceEpoch,
/// The decoded <key /> elements. from the header. Note that we only include the ones /// The decoded <key /> elements. from the header. Note that we only include the ones
/// relevant for Bob, so all children of <keys jid='$bobJid' />. /// relevant for Bob, so all children of <keys jid='$bobJid' />.
keys, keys,

View File

@ -1,12 +1,15 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1656065134, "lastModified": 1692799911,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,16 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1657540956, "lastModified": 1727586919,
"narHash": "sha256-ihGbOFWtAkENwxBE5kV/yWt2MncvW+BObLDsmxCLo/Q=", "narHash": "sha256-e/YXG0tO5GWHDS8QQauj8aj4HhXEm602q9swrrlTlKQ=",
"owner": "NANASHI0X74", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "043de04db8a6b0391b3fefaaade160514d866946", "rev": "2dcd9c55e8914017226f5948ac22c53872a13ee2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NANASHI0X74", "owner": "NixOS",
"ref": "flutter-3-0-0", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -36,6 +39,21 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -1,7 +1,7 @@
{ {
description = "omemo_dart"; description = "omemo_dart";
inputs = { inputs = {
nixpkgs.url = "github:NANASHI0X74/nixpkgs/flutter-3-0-0"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let

View File

@ -1,27 +1,27 @@
name: omemo_dart name: omemo_dart
description: An XMPP library independent OMEMO library description: An XMPP library independent OMEMO library
version: 0.5.1 version: 0.6.0
homepage: https://github.com/PapaTutuWawa/omemo_dart homepage: https://github.com/PapaTutuWawa/omemo_dart
publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub
environment: environment:
sdk: '>=2.17.0 <3.0.0' sdk: ">=3.0.0 <4.0.0"
dependencies: dependencies:
collection: ^1.16.0 collection: ^1.18.0
cryptography: ^2.0.5 cryptography: ^2.7.0
hex: ^0.2.0 hex: ^0.2.0
logging: ^1.0.2 logging: ^1.2.0
meta: ^1.7.0 meta: ^1.15.0
moxlib: moxlib:
version: ^0.2.0 version: ^0.2.0
hosted: https://git.polynom.me/api/packages/Moxxy/pub hosted: https://git.polynom.me/api/packages/Moxxy/pub
pinenacl: ^0.5.1 pinenacl: ^0.6.0
protobuf: ^2.1.0 protobuf: ^3.1.0
protoc_plugin: ^20.0.1 protoc_plugin: ^21.1.2
synchronized: ^3.0.0+2 synchronized: ^3.3.0+3
dev_dependencies: dev_dependencies:
lints: ^2.0.0 lints: ^5.0.0
test: ^1.21.0 test: ^1.25.8
very_good_analysis: ^3.0.1 very_good_analysis: ^6.0.0