Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags and Encryption API #108

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ app.*.map.json
/android/app/release

.flutter-plugins-dependencies
.flutter-plugins
.flutter-plugins


.env
2 changes: 1 addition & 1 deletion examples/demo_app/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions examples/demo_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe
flutter_webrtc: 55df3aaa802114dad390191a46c2c8d535751268
image_cropper: a3291c624a953049bc6a02e1f8c8ceb162a24b25
Expand All @@ -104,4 +104,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f9420bd595da8fbce156b547dcd3368afc5226ff

COCOAPODS: 1.14.2
COCOAPODS: 1.15.2
8 changes: 4 additions & 4 deletions examples/demo_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -451,7 +451,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -580,7 +580,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -629,7 +629,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
5 changes: 1 addition & 4 deletions examples/demo_app/lib/views/account_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ class AccountProvider extends ChangeNotifier {
pushUser = await PushAPI.initialize(
signer: Web3Signer(wallet),
options: PushAPIInitializeOptions(
account: user.address.toLowerCase(),
env: env,
showHttpLog: true
),
account: user.address.toLowerCase(), env: env, showHttpLog: true),
);

creatSocketConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class SendSpaceInviteDialog extends ConsumerStatefulWidget {
final bool isSpeaker;

@override
ConsumerState<SendSpaceInviteDialog> createState() => _SendSpaceInviteDialogState();
ConsumerState<SendSpaceInviteDialog> createState() =>
_SendSpaceInviteDialogState();
}

class _SendSpaceInviteDialogState extends ConsumerState<SendSpaceInviteDialog> {
Expand Down
32 changes: 32 additions & 0 deletions examples/use_cases/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# MAKE A COPY OF THIS AND FILL WITH YOUR CREDENTIALS AND NAME IT .env (Remove .sample Part)

# ENVIRONMENT | 'STAGING' or 'PROD' or 'DEV'
ENV=env_name

## CHANNEL WITH ALIAS
BERACHAIN_CHANNEL_PRIVATE_KEY=your_berachain_channel_private_key
LINEA_CHANNEL_PRIVATE_KEY=your_linea_channel_private_key
ARBITRUM_CHANNEL_PRIVATE_KEY=your_arbitrum_channel_private_key
OPTIMISM_CHANNEL_PRIVATE_KEY=your_optimism_channel_private_key
POLYGON_CHANNEL_PRIVATE_KEY=your_polygon_channel_private_key
POLYGON_ZKEVM_CHANNEL_PRIVATE_KEY=your_polygon_zkevm_channel_private_key
CYBER_CONNECT_CHANNEL_PRIVATE_KEY=your_cyber_connect_channel_private_key

WALLET_PRIVATE_KEY=your_wallet_private_key
WALLET_PRIVATE_KEY_2=your_wallet_private_key_2
WALLET_RECIPIENT_PK=your_wallet_recipient_pk
NFT_PROFILE_PASSWORD_1=nft_profile_password_1
NFT_PROFILE_PASSWORD_2=nft_profile_password_2
NFT_PROFILE_PASSWORD_3=nft_profile_password_3
NFT_CONTRACT_ADDRESS_1=nft_contract_address_1
NFT_CHAIN_ID_1=nft_chain_id_1
NFT_TOKEN_ID_1=nft_token_id_1
NFT_HOLDER_WALLET_PRIVATE_KEY_1=nft_holder_wallet_private_key_1
NFT_CONTRACT_ADDRESS_2=nft_contract_address_2
NFT_CHAIN_ID_2=nft_chain_id_2
NFT_TOKEN_ID_2=nft_token_id_2
NFT_HOLDER_WALLET_PRIVATE_KEY_2=nft_holder_wallet_private_key_2
NFT_CONTRACT_ADDRESS_3=nft_contract_address_3
NFT_CHAIN_ID_3=nft_chain_id_3
NFT_TOKEN_ID_3=nft_token_id_3
NFT_HOLDER_WALLET_PRIVATE_KEY_3=nft_holder_wallet_private_key_3
2 changes: 1 addition & 1 deletion examples/use_cases/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions examples/use_cases/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_webrtc: 55df3aaa802114dad390191a46c2c8d535751268
livekit_client: 381ed3cad6ba0b6ffbfffcf1b5db95ad1e61ffa2
openpgp: 7d9e62ab7cd0cf9f70a425956ea6cccfc1b5241a
Expand All @@ -62,4 +62,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f9420bd595da8fbce156b547dcd3368afc5226ff

COCOAPODS: 1.14.2
COCOAPODS: 1.15.2
8 changes: 4 additions & 4 deletions examples/use_cases/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -452,7 +452,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -579,7 +579,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -628,7 +628,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 6 additions & 0 deletions examples/use_cases/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:use_cases/chats/chat.dart';

import 'pushAPI/notificaton/notification.test.dart';

void main() async {
await dotenv.load(fileName: ".env");

runApp(const MainApp());
runNotificationTest();

log(r'''

Expand Down
2 changes: 1 addition & 1 deletion examples/use_cases/lib/models/signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Web3Signer extends push.Signer {
final web3.Credentials credentials;

Web3Signer(this.credentials);
String get address=> getAddress();
String get address => getAddress();

@override
String getAddress() {
Expand Down
73 changes: 73 additions & 0 deletions examples/use_cases/lib/pushAPI/encryption.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'dart:math';

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:push_restapi_dart/push_restapi_dart.dart';
import 'package:ethers/signers/wallet.dart' as ether;
import 'package:web3dart/web3dart.dart' as web3;
import '../../models/signer.dart';

void main() async {
await dotenv.load(fileName: ".env");
runEncryptionUpdateTest();
}

//'PushAPI.encryption functionality'
runEncryptionTest() async {
log("runNotificationTest() started...");
final signer1PK = dotenv.get('WALLET_PRIVATE_KEY');

final ethersWallet1 = ether.Wallet.fromPrivateKey(signer1PK);

final signer1 = EthersSigner(
ethersWallet: ethersWallet1,
address: ethersWallet1.address!,
);

final userAlice = await PushAPI.initialize(
signer: signer1,
options: PushAPIInitializeOptions(env: ENV.staging),
);

final response = await userAlice.encryption.info();

final data = response as Map<String, dynamic>;
if ((data['decryptedPgpPrivateKey'] as String)
.contains('-----BEGIN PGP PRIVATE KEY BLOCK-----\n')) {
log('decryptedPgpPrivateKey has -----BEGIN PGP PRIVATE KEY BLOCK-----\n');
}
if ((data['pgpPublicKey'] as String)
.contains('-----BEGIN PGP PUBLIC KEY BLOCK-----\n')) {
log('pgpPublicKey has-----BEGIN PGP PUBLIC KEY BLOCK-----\n');
}
}

runEncryptionUpdateTest() async {
log("runNotificationTest() started...");

var random = Random.secure();
final wallet = web3.EthPrivateKey.createRandom(random);

// final ethersWallet1 = ether.Wallet.fromPrivateKey(wallet.privateKey);

final signer1 = Web3Signer(wallet);

final userAlice = await PushAPI.initialize(
signer: signer1,
options: PushAPIInitializeOptions(env: ENV.staging),
);

await userAlice.encryption
.update(updatedEncryptionType: EncryptionType.PGP_V3);

final response = await userAlice.encryption.info();

final data = response as Map<String, dynamic>;
if ((data['decryptedPgpPrivateKey'] as String)
.contains('-----BEGIN PGP PRIVATE KEY BLOCK-----\n')) {
log('decryptedPgpPrivateKey has -----BEGIN PGP PRIVATE KEY BLOCK-----\n');
}
if ((data['pgpPublicKey'] as String)
.contains('-----BEGIN PGP PUBLIC KEY BLOCK-----\n')) {
log('pgpPublicKey has-----BEGIN PGP PUBLIC KEY BLOCK-----\n');
}
}
31 changes: 31 additions & 0 deletions examples/use_cases/lib/pushAPI/notificaton/notification.test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:push_restapi_dart/push_restapi_dart.dart';
import 'package:ethers/signers/wallet.dart' as ether;

import '../../models/signer.dart';

runNotificationTest() async {
log("runNotificationTest() started...");
final signer1PK = dotenv.get('WALLET_PRIVATE_KEY');

final ethersWallet1 = ether.Wallet.fromPrivateKey(signer1PK);

final signer1 = EthersSigner(
ethersWallet: ethersWallet1,
address: ethersWallet1.address!,
);

final userAlice = await PushAPI.initialize(
signer: signer1,
options: PushAPIInitializeOptions(env: ENV.staging),
);

log('PushAPI.notification.subscribe');
final subscribeResponse = await userAlice.notification.subscribe(
channel:
'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681' // channel to subscribe
);

log(subscribeResponse);
log('PushAPI.notification.subscribe | Response - 200 OK\n\n');
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void testApproveIntent() async {
final user = await getUser(address: ethersWallet.address!);

if (user == null) {
print('Cannot get user');
return;
}

Expand All @@ -26,11 +25,10 @@ void testApproveIntent() async {
wallet: getWallet(signer: signer),
);
}
final result = await requests(
await requests(
toDecrypt: true,
accountAddress: signer.address,
pgpPrivateKey: pgpPrivateKey);
print(result);
approve(
senderAddress: "0xaba32d63052de97Bc3bc749b7241cB4E2479c401",
account: signer.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:push_restapi_dart/push_restapi_dart.dart' as push;
import 'package:use_cases/models/signer.dart';
import 'package:web3dart/web3dart.dart' as web3;


void testSendNotificationFromChannel() async {}

void testSendVideoCallNotification() async {
Expand Down
1 change: 0 additions & 1 deletion examples/use_cases/lib/test_functions/pushapi/pushapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:push_restapi_dart/push_restapi_dart.dart';
import 'package:use_cases/models/signer.dart';
import 'package:web3dart/web3dart.dart' as web3;


testPushApi() async {
final web3.Credentials randomCredentials =
web3.EthPrivateKey.createRandom(Random.secure());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:push_restapi_dart/push_restapi_dart.dart' as push;

import 'package:ethers/signers/wallet.dart' as ether;
Expand Down
6 changes: 6 additions & 0 deletions examples/use_cases/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
path: '../../'
unique_names_generator: ^1.0.0
logger: ^2.0.2+1
flutter_dotenv: ^5.1.0

dev_dependencies:
flutter_test:
Expand All @@ -29,3 +30,8 @@ dev_dependencies:

flutter:
uses-material-design: true

assets:
- .env


1 change: 1 addition & 0 deletions lib/src/channels/channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export 'src/subscribe.dart';
export 'src/subscribeV2.dart';
export 'src/unsubscribe.dart';
export 'src/unsubscribeV2.dart';
export 'src/get_tags.dart';
Loading