Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebdeveloper6952/amberflutter
Flutter wrapper for Amber (Nostr Signer)
https://github.com/sebdeveloper6952/amberflutter
Last synced: 24 days ago
JSON representation
Flutter wrapper for Amber (Nostr Signer)
- Host: GitHub
- URL: https://github.com/sebdeveloper6952/amberflutter
- Owner: sebdeveloper6952
- License: mit
- Created: 2023-12-01T07:25:49.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-01T16:11:50.000Z (12 months ago)
- Last Synced: 2024-04-28T04:41:24.824Z (8 months ago)
- Language: Dart
- Size: 133 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nostr - amberflutter - A Flutter wrapper for Amber (Offline Signer). (Libraries / Client reviews and/or comparisons)
README
# amberflutter
A Flutter wrapper for [Amber](https://github.com/greenart7c3/Amber/tree/master) (Nostr Signer).
## Rationale
Provide a bridge between your app and Amber, to enable app developers to easily use the functionality provided by Amber.
## Installation
With flutter:
```
flutter pub add amberflutter
```Or add to your `pubspec.yaml`:
```
dependencies:
amberflutter: ^0.0.1
```## Usage
Documentation is taken from [Amber Docs](https://github.com/greenart7c3/Amber/blob/master/README.md). Please refer to them if you have any question about how to use Amber.
_Import in your code_
```
import 'package:amberflutter/amberflutter.dart';
```_Get Public Key_
Get the current user public key (npub). This request also allows to send permissions so the user can approve them forever. See the [Amber Docs](https://github.com/greenart7c3/Amber/blob/master/README.md) for the list of available permissions.
```
final amber = Amberflutter();amber.getPublicKey(
permissions: [
Permission(
type: "sign_event",
),
],
).then((value) {
print("npub: ${value['signature']}");
});
```_Sign Event_
```
final amber = Amberflutter();
final eventJson = jsonEncode({
'id': '',
'pubkey': Nip19.decodePubkey(_npub),
'kind': 1,
'content': 'Hello from Amber Flutter!',
'created_at':
(DateTime.now().millisecondsSinceEpoch / 1000).round(),
'tags': [],
'sig': '',
});amber.signEvent(
currentUser: "",
eventJson: eventJson,
).then((value) {
print("signed event: ${value['event']}");
});
```_Nip 04 Encrypt_
```
final amber = Amberflutter();amber.nip04Encrypt(
plaintext: "Hello from Amber Flutter, Nip 04!",
currentUser: "",
pubKey: "",
).then((value) {
print("ciphertext: ${value['signature']}")
});
```_Nip 44 Encrypt_
```
amber.nip44Encrypt(
plaintext: "Hello from Amber Flutter, Nip 44!",
currentUser: "",
pubKey: "",
).then((value) {
print("ciphertext: ${value['signature']}")
});
```_Nip 04 Decrypt_
```
final amber = Amberflutter();amber.nip04Decrypt(
ciphertext: "",
currentUser: "",
pubKey: "",
).then((value) {
print("plaintext: ${value['signature']}")
});
```_Nip 44 Decrypt_
```
final amber = Amberflutter();amber.nip44Decrypt(
ciphertext: "",
currentUser: "",
pubKey: "",
).then((value) {
print("plaintext: ${value['signature']}")
});
```