feat(block2): profiles — your identity card + name/about (NIP-01 kind:0)
Drawer 'Profile' is now live. - commons_core: ProfileTransport + UserProfile + NostrProfileTransport (kind:0 publish/fetch), exposed as SocialSession.profile. Round-trip tested against the in-process relay (fast dart test). - app: ProfileStore (local name/about, keystore) + ProfileScreen — shows your shareable npub with copy, edits display name + 'about', saves locally and (when online) publishes kind:0 so peers can recognise you instead of a raw key. - Drawer 'Profile' -> /profile (gated like Market/Chat). - i18n en/es/pt. ProfileStore + profile transport covered by plain/dart tests. Analyzer clean (both packages).
This commit is contained in:
parent
7f1c520960
commit
8ef587176f
19 changed files with 562 additions and 4 deletions
46
packages/commons_core/test/social/nostr_profile_test.dart
Normal file
46
packages/commons_core/test/social/nostr_profile_test.dart
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:commons_core/commons_core.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../support/mini_relay.dart';
|
||||
|
||||
void main() {
|
||||
Future<NostrIdentity> idFor(int fill) =>
|
||||
NostrKeyDerivation.deriveFromSeed(Uint8List(32)..fillRange(0, 32, fill));
|
||||
|
||||
late MiniRelay relay;
|
||||
setUp(() async => relay = await MiniRelay.start());
|
||||
tearDown(() async => relay.stop());
|
||||
|
||||
test('publish then fetch round-trips a profile (kind:0)', () async {
|
||||
final alice = await idFor(1);
|
||||
final aliceConn = await NostrConnection.connect(relay.url, identity: alice);
|
||||
await NostrProfileTransport(aliceConn)
|
||||
.publish(name: 'Alicia', about: 'Guardo tomate rosa');
|
||||
|
||||
// Anyone else can fetch it.
|
||||
final bob = await idFor(2);
|
||||
final bobConn = await NostrConnection.connect(relay.url, identity: bob);
|
||||
final fetched =
|
||||
await NostrProfileTransport(bobConn).fetch(alice.publicKeyHex);
|
||||
|
||||
expect(fetched, isNotNull);
|
||||
expect(fetched!.name, 'Alicia');
|
||||
expect(fetched.about, 'Guardo tomate rosa');
|
||||
|
||||
await aliceConn.close();
|
||||
await bobConn.close();
|
||||
});
|
||||
|
||||
test('fetch returns null when the peer never published a profile', () async {
|
||||
final me = await idFor(3);
|
||||
final conn = await NostrConnection.connect(relay.url, identity: me);
|
||||
final stranger = await idFor(9);
|
||||
expect(
|
||||
await NostrProfileTransport(conn).fetch(stranger.publicKeyHex),
|
||||
isNull,
|
||||
);
|
||||
await conn.close();
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue