amberflutter

Creator: coderz1093

Last updated:

0 purchases

amberflutter Image
amberflutter Images

Languages

Categories

Add to Cart

Description:

amberflutter

amberflutter #
A Flutter wrapper for Amber (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
copied to clipboard
Or add to your pubspec.yaml:
dependencies:
amberflutter: ^0.0.1
copied to clipboard
Usage #
Documentation is taken from Amber Docs. Please refer to them if you have any question about how to use Amber.
Import in your code
import 'package:amberflutter/amberflutter.dart';
copied to clipboard
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 for the list of available permissions.
final amber = Amberflutter();

amber.getPublicKey(
permissions: [
Permission(
type: "sign_event",
),
],
).then((value) {
print("npub: ${value['signature']}");
});
copied to clipboard
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: "<your_npub_here>",
eventJson: eventJson,
).then((value) {
print("signed event: ${value['event']}");
});
copied to clipboard
Nip 04 Encrypt
final amber = Amberflutter();

amber.nip04Encrypt(
plaintext: "Hello from Amber Flutter, Nip 04!",
currentUser: "<your_npub_here>",
pubKey: "<hex_pubkey_to_encrypt>",
).then((value) {
print("ciphertext: ${value['signature']}")
});
copied to clipboard
Nip 44 Encrypt
amber.nip44Encrypt(
plaintext: "Hello from Amber Flutter, Nip 44!",
currentUser: "<your_npub_here>",
pubKey: "<hex_pubkey_to_encrypt>",
).then((value) {
print("ciphertext: ${value['signature']}")
});
copied to clipboard
Nip 04 Decrypt
final amber = Amberflutter();

amber.nip04Decrypt(
ciphertext: "<message_encrypted_with_nip04_here>",
currentUser: "<your_npub_here>",
pubKey: "<hex_pubkey_to_decrypt>",
).then((value) {
print("plaintext: ${value['signature']}")
});
copied to clipboard
Nip 44 Decrypt
final amber = Amberflutter();

amber.nip44Decrypt(
ciphertext: "<message_encrypted_with_nip44_here>",
currentUser: "<your_npub_here>",
pubKey: "<hex_pubkey_to_decrypt>",
).then((value) {
print("plaintext: ${value['signature']}")
});
copied to clipboard
Detect if Amber is installed in users's device
final amber = Amberflutter();

amber.isAppInstalled().then((value) {
print("Amber is installed: $value")
});
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.