Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion .codex/skills/flutter-pub-release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,32 @@ python3 .codex/skills/flutter-pub-release/scripts/release_helper.py apply <packa
- `packages/<package>/CHANGELOG.md`
- `packages/<package>/example/pubspec.lock` when present

- Then run dependency resolution from the package directory so lock/state stays consistent with the new version:

```bash
cd packages/<package>
dart pub get
```

4. Validate narrowly.
- Run package-scoped checks only when they are fast and relevant.
- Do not expand into repo-wide validation unless the change genuinely spans packages.

5. Commit and push before drafting the release.
5. Commit and run publish dry-run before drafting the release.
- Use an English commit message such as:

```text
chore(release): prepare <package> <version>
```

- Commit the release changes directly on `main`.
- After commit, run a publish dry-run from the package directory and fix any reported errors before pushing:

```bash
cd packages/<package>
dart pub publish --dry-run
```

- Push `main`.

6. Draft the GitHub release.
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"chat.tools.terminal.autoApprove": {
"dart": true
}
}
112 changes: 59 additions & 53 deletions packages/common_crypto/test/aes_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';

import 'package:common_crypto/common_crypto.dart';
Expand All @@ -11,30 +12,11 @@ Uint8List generateRandomBytes([int length = 32]) =>
Uint8List.fromList(List<int>.generate(length, (i) => _random.nextInt(256)));

void main() {
test('aseTest', () {
final source = Uint8List.fromList(utf8.encode('mixin'));
final key = generateRandomBytes(16);
final iv = generateRandomBytes(16);
final encrypted = aesEncrypt(
key: key,
data: source,
iv: iv,
);
final decrypted = aesDecrypt(
key: key,
data: encrypted,
iv: iv,
);
assert(listEquals(source, decrypted));
});

test('benchmark', () {
final source = generateRandomBytes(1024 * 10); // 10kb data
var totalTime = Duration.zero;
for (var i = 0; i < 10000; i++) {
group('aes', () {
test('aseTest', () {
final source = Uint8List.fromList(utf8.encode('mixin'));
final key = generateRandomBytes(16);
final iv = generateRandomBytes(16);
final stopwatch = Stopwatch()..start();
final encrypted = aesEncrypt(
key: key,
data: source,
Expand All @@ -45,43 +27,67 @@ void main() {
data: encrypted,
iv: iv,
);
totalTime += stopwatch.elapsed;
if (i % 1000 == 0) {
debugPrint('benchmark aesEncrypt/aesDecrypt: $i times');
}
assert(listEquals(source, decrypted));
}
debugPrint('benchmark aesEncrypt/aesDecrypt: $totalTime');
});
});

test('random encrypt test', () {
final random = Random.secure();
for (var start = 0; start < 10; start++) {
debugPrint('random encrypt test: $start');
final key = generateRandomBytes(16);
final iv = generateRandomBytes(16);
test('benchmark', () {
final source = generateRandomBytes(1024 * 10); // 10kb data
var totalTime = Duration.zero;
for (var i = 0; i < 10000; i++) {
final key = generateRandomBytes(16);
final iv = generateRandomBytes(16);
final stopwatch = Stopwatch()..start();
final encrypted = aesEncrypt(
key: key,
data: source,
iv: iv,
);
final decrypted = aesDecrypt(
key: key,
data: encrypted,
iv: iv,
);
totalTime += stopwatch.elapsed;
if (i % 1000 == 0) {
debugPrint('benchmark aesEncrypt/aesDecrypt: $i times');
}
assert(listEquals(source, decrypted));
}
debugPrint('benchmark aesEncrypt/aesDecrypt: $totalTime');
});

final hMacKey = generateRandomBytes();
test('random encrypt test', () {
final random = Random.secure();
for (var start = 0; start < 10; start++) {
debugPrint('random encrypt test: $start');
final key = generateRandomBytes(16);
final iv = generateRandomBytes(16);

final encryptor = AesCryptor(encrypt: true, key: key, iv: iv);
final decryptor = AesCryptor(encrypt: false, key: key, iv: iv);
final hMacKey = generateRandomBytes();

final sourceHMac = HMacSha256(hMacKey);
final targetHMac = HMacSha256(hMacKey);
final encryptor = AesCryptor(encrypt: true, key: key, iv: iv);
final decryptor = AesCryptor(encrypt: false, key: key, iv: iv);

for (var i = 0; i < 500; i++) {
final source = generateRandomBytes(random.nextInt(1024));
sourceHMac.update(source);
final decrypted = decryptor.update(encryptor.update(source));
targetHMac.update(decrypted);
}
final sourceHMac = HMacSha256(hMacKey);
final targetHMac = HMacSha256(hMacKey);

for (var i = 0; i < 500; i++) {
final source = generateRandomBytes(random.nextInt(1024));
sourceHMac.update(source);
final decrypted = decryptor.update(encryptor.update(source));
targetHMac.update(decrypted);
}

targetHMac.update(decryptor.update(encryptor.finalize()));
targetHMac.update(decryptor.finalize());
targetHMac.update(decryptor.update(encryptor.finalize()));
targetHMac.update(decryptor.finalize());

final sourceResult = sourceHMac.finalize();
final targetResult = targetHMac.finalize();
expect(base64Encode(sourceResult), base64Encode(targetResult));
}
});
final sourceResult = sourceHMac.finalize();
final targetResult = targetHMac.finalize();
expect(base64Encode(sourceResult), base64Encode(targetResult));
}
});
}, skip: _skipOnNonMacOS);
}

final Object _skipOnNonMacOS =
Platform.isMacOS ? false : 'common_crypto tests require macOS CommonCrypto';
71 changes: 39 additions & 32 deletions packages/common_crypto/test/hmac_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

Expand All @@ -10,38 +11,44 @@ import 'package:pointycastle/export.dart';
import 'aes_test.dart';

void main() {
test('hmac 256 test', () {
final key = base64Decode('Y9hRHsqr9adyX29DYsjWhg==');
final data = Uint8List.fromList(utf8.encode('Mixin'));
final result = HMacSha256.hmacSha256(key: key, data: data);
expect(
base64Encode(result),
equals('Zg/Z5GkXYHKPR/uPVOe4Z5ZPzSgRoDL72mrm5/TyCrQ='),
);
});

test('random generate hmac', () {
final random = Random.secure();
for (var start = 0; start < 10; start++) {
final hMacKey = generateRandomBytes();
final commonCryptoHMac = HMacSha256(hMacKey);
final pointyHMac = HMac(SHA256Digest(), 64)..init(KeyParameter(hMacKey));

final data = random.nextInt(1024);
for (var i = 0; i < data; i++) {
final bytes = generateRandomBytes(random.nextInt(1024));
commonCryptoHMac.update(bytes);
pointyHMac.update(bytes, 0, bytes.length);
}
group('hmac', () {
test('hmac 256 test', () {
final key = base64Decode('Y9hRHsqr9adyX29DYsjWhg==');
final data = Uint8List.fromList(utf8.encode('Mixin'));
final result = HMacSha256.hmacSha256(key: key, data: data);
expect(
base64Encode(result),
equals('Zg/Z5GkXYHKPR/uPVOe4Z5ZPzSgRoDL72mrm5/TyCrQ='),
);
});

test('random generate hmac', () {
final random = Random.secure();
for (var start = 0; start < 10; start++) {
final hMacKey = generateRandomBytes();
final commonCryptoHMac = HMacSha256(hMacKey);
final pointyHMac = HMac(SHA256Digest(), 64)
..init(KeyParameter(hMacKey));

final data = random.nextInt(1024);
for (var i = 0; i < data; i++) {
final bytes = generateRandomBytes(random.nextInt(1024));
commonCryptoHMac.update(bytes);
pointyHMac.update(bytes, 0, bytes.length);
}

final commonCryptoResult = commonCryptoHMac.finalize();
final bytes = Uint8List(pointyHMac.macSize);
final len = pointyHMac.doFinal(bytes, 0);
final pointyResult = bytes.sublist(0, len);
final commonCryptoResult = commonCryptoHMac.finalize();
final bytes = Uint8List(pointyHMac.macSize);
final len = pointyHMac.doFinal(bytes, 0);
final pointyResult = bytes.sublist(0, len);

debugPrint('commonCryptoResult: ${base64Encode(commonCryptoResult)} '
'pointyResult: ${base64Encode(pointyResult)}');
expect(commonCryptoResult, equals(pointyResult));
}
});
debugPrint('commonCryptoResult: ${base64Encode(commonCryptoResult)} '
'pointyResult: ${base64Encode(pointyResult)}');
expect(commonCryptoResult, equals(pointyResult));
}
});
}, skip: _skipOnNonMacOS);
}

final Object _skipOnNonMacOS =
Platform.isMacOS ? false : 'common_crypto tests require macOS CommonCrypto';
9 changes: 1 addition & 8 deletions packages/mixin_markdown_widget/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@

## 0.1.0

- Initial implementation of `MarkdownWidget`, `MarkdownController`, and `MarkdownThemeData`
- Added block-based document model and Markdown parser adapter
- Added renderers for common Markdown blocks and a desktop demo example
- Added plain-text serialization, copy-all actions, and streaming draft state APIs
- Added `MarkdownSelectionController` and selection-aware plain-text range serialization
- Added custom drag selection, keyboard shortcuts, block/word selection gestures, and a custom context menu for selection copy flows
- Added syntax-highlighted code blocks with character-level custom selection
- Added table cell range selection and TSV/plain-text copy support
- Initial implementation
22 changes: 21 additions & 1 deletion packages/mixin_markdown_widget/LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
TODO: Add your license here.
MIT License

Copyright (c) 2026 Mixin Network

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions packages/mixin_markdown_widget/example/devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
Loading
Loading