Skip to content

Commit

Permalink
Merge pull request #250 from syphon-org/upgrade-dart-2
Browse files Browse the repository at this point in the history
[Maintenance] Upgrades for Dart 2
  • Loading branch information
ereio authored May 23, 2021
2 parents 000cf8b + 1b1317b commit c23a030
Show file tree
Hide file tree
Showing 207 changed files with 5,459 additions and 5,339 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

2 changes: 0 additions & 2 deletions .env.debug

This file was deleted.

2 changes: 0 additions & 2 deletions .env.release

This file was deleted.

4 changes: 4 additions & 0 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "2.0.6",
"flavors": {}
}
32 changes: 32 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Changes

### 🔮 Features
### 🔒 Security
### 🛠 Performance
### 🐛 Fixes
### 📐 Refactoring

### Media (if applicable)

### Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

### QA

- [ ] Signup
- [ ] Login
- [ ] Logout
- [ ] Unencrypted Chat
- [ ] Encrypted Chat
- [ ] Group Chats
- [ ] Profile Changes
- [ ] Themeing Changes
- [ ] Force Kill and Restart

### Final Checklist

- [ ] All associated issues have been linked to PR
- [ ] All necessary changes made to the documentation
- [ ] Parties interested in these changes have been notified
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ macos/olm
Flutter.podspec

# vscode workspace
*.code-workspace
*.code-workspace

# flutter version mgmt
.fvm/flutter_sdk
27 changes: 27 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
include: package:lint/analysis_options.yaml

# TODO: implicit casts should be fine, but we'll play the game later
analyzer:
strong-mode:
implicit-casts: true

linter:
rules:
# Disabled
type_annotate_public_apis: false
avoid_classes_with_only_static_members: false
always_declare_return_types: false # can be explicit in declaration
constant_identifier_names: false

# Enabled
prefer_single_quotes: true

# sort_constructors_first: true
# prefer_double_quotes: true
# public_member_api_docs: true
# always_specify_types: true
# always_put_required_named_parameters_first: false

# TODO:
prefer_const_constructors: false
lines_longer_than_80_chars: false
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ android {
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 1 addition & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
org.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home
distributionSha256Sum=3fd824892df8ad5847be6e4fb7d3600068437de172939fd657cc280a1a629f63
43 changes: 43 additions & 0 deletions assets/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,47 @@ flutter_recaptcha_v2: 0.1.0 used as reference for webview captcha
break;
}
}
```


```dart
// TODO: refactor sync device and/or use this one?
ThunkAction<AppState> syncDeviceNew(Map dataToDevice) {
return (Store<AppState> store) async {
try {
// Extract the new events
final List<dynamic> events = dataToDevice['events'];
// Parse and decrypt necessary events
for (final event in events) {
final eventType = event['type'];
final identityKeySender = event['content']['sender_key'];
switch (eventType) {
case EventTypes.encrypted:
final eventDecrypted = await store.dispatch(
decryptKeyEvent(event: event),
);
if (EventTypes.roomKey == eventDecrypted['type']) {
await store.dispatch(
saveSessionKey(
event: eventDecrypted,
identityKey: identityKeySender,
),
);
}
break;
default:
break;
}
}
} catch (error) {
store.dispatch(addAlert(
error: error,
origin: 'syncDevice',
));
}
};
}
```
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions ios/Flutter/Flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#

Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.vendored_frameworks = 'Flutter.framework'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end
18 changes: 9 additions & 9 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PODS:
- DKPhotoGallery/Resource (0.0.17):
- SDWebImage
- SwiftyGif
- emoji_picker (0.0.3):
- emoji_picker_flutter (0.0.1):
- Flutter
- file_picker (0.0.1):
- DKImagePickerController/PhotoGallery
Expand Down Expand Up @@ -92,7 +92,7 @@ PODS:

DEPENDENCIES:
- device_info (from `.symlinks/plugins/device_info/ios`)
- emoji_picker (from `.symlinks/plugins/emoji_picker/ios`)
- emoji_picker_flutter (from `.symlinks/plugins/emoji_picker_flutter/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
Expand Down Expand Up @@ -121,8 +121,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
device_info:
:path: ".symlinks/plugins/device_info/ios"
emoji_picker:
:path: ".symlinks/plugins/emoji_picker/ios"
emoji_picker_flutter:
:path: ".symlinks/plugins/emoji_picker_flutter/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
Flutter:
Expand Down Expand Up @@ -154,13 +154,13 @@ SPEC CHECKSUMS:
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
emoji_picker: 0e868059aa18f9473d234f3d0701fbd4d5fd310c
emoji_picker_flutter: 4f9a1ac31d355e1bf9622a1e821a809149130127
file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09
image_picker: 50e7c7ff960e5f58faa4d1f4af84a771c671bc4a
OLMKit: 4ee0159d63feeb86d836fdcfefe418e163511639
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
Expand All @@ -172,7 +172,7 @@ SPEC CHECKSUMS:
SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b

PODFILE CHECKSUM: 127d285aa3bfad2bbd68630172869bd951e40542

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions lib/cache/codec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:encrypt/encrypt.dart';

const IV_LENGTH = 16;
const IV_LENGTH_BASE_64 = (IV_LENGTH + (IV_LENGTH / 2));

/// Random bytes generator
Uint8List _generateIV(int length) {
return IV.fromSecureRandom(length).bytes;
}

/// Generate an encryption password based on a user input password
Key _generateEncryptPassword(String password) {
return Key.fromBase64(password);
}

class _EncryptEncoder extends Converter<String, String> {
final AES aes;

_EncryptEncoder(this.aes);

@override
String convert(String input) {
// Generate random initial value
final iv = _generateIV(IV_LENGTH);
final ivEncoded = base64.encode(iv);
assert(ivEncoded.length == IV_LENGTH_BASE_64.round());

// Encode the input value
final encoded = Encrypter(aes).encrypt(input, iv: IV(iv)).base64;

// Prepend the initial value
return '$ivEncoded$encoded';
}
}

class _EncryptDecoder extends Converter<String, String> {
final AES aes;

_EncryptDecoder(this.aes);

@override
String convert(String input) {
// Read the initial value that was prepended
assert(input.length >= IV_LENGTH_BASE_64.round());
final iv = base64.decode(input.substring(0, IV_LENGTH_BASE_64.round()));

// Extract the real input
input = input.substring(IV_LENGTH_BASE_64.round());

// Decode the input
return Encrypter(aes).decrypt64(input, iv: IV(iv));
}
}

/// Salsa20 based Codec
class EncryptCodec extends Codec<String, String> {
late _EncryptEncoder _encoder;
late _EncryptDecoder _decoder;

EncryptCodec(Key passwordBytes) {
var aes = AES(passwordBytes, mode: AESMode.ctr, padding: null);

_encoder = _EncryptEncoder(aes);
_decoder = _EncryptDecoder(aes);
}

@override
Converter<String, String> get decoder => _decoder;

@override
Converter<String, String> get encoder => _encoder;
}

EncryptCodec initCacheEncrypter({required String password}) =>
EncryptCodec(_generateEncryptPassword(password));
Loading

0 comments on commit c23a030

Please sign in to comment.