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

Implement PushStream highlevel api in SDK #95

Merged
merged 21 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f56def8
Scalability changes: modify update group methods (#67)
gbogboadePush Dec 5, 2023
c0e9f02
Scalability changes: add pgpv2 encryption in approve request (#68)
gbogboadePush Dec 6, 2023
31afa6e
Delete .DS_Store
madhur-push Dec 13, 2023
9b1ad8c
Implement scalability changes in encryption and decryption of message…
gbogboadePush Dec 13, 2023
e65148b
Remove the user property from the ConnectedUser class (#75)
gbogboadePush Dec 14, 2023
541b83e
Update example app to incorporate scalability changes (#80)
gbogboadePush Dec 20, 2023
605aa65
Merge remote-tracking branch 'origin/chat-scalability-changes-v1' int…
Gbogboade1 Dec 20, 2023
32fa1d9
feat: add PushApi class
Gbogboade1 Dec 21, 2023
dfb9524
feat: add list,latest,history and send to Chat in PushApi clases
Gbogboade1 Dec 21, 2023
a39b915
feat: add Chat Api class functions
Gbogboade1 Dec 22, 2023
4c46c51
Merge remote-tracking branch 'origin/main' into class-based-sdk-api
Gbogboade1 Jan 2, 2024
9d27b5f
feat: add all Chat class API functions
Gbogboade1 Jan 3, 2024
8be6679
chore: add demo_app and use_cases modules to example
Gbogboade1 Jan 4, 2024
0372baa
feat: add chat functions
Gbogboade1 Jan 5, 2024
9d20e0f
feat: add chat use cases
Gbogboade1 Jan 8, 2024
39021b6
chore: remove unneccesary log
Gbogboade1 Jan 8, 2024
fc08761
feat: add stream highlevel api in SDK
Gbogboade1 Jan 10, 2024
f7dba24
Merge remote-tracking branch 'origin/main' into push-stream-class-bas…
Gbogboade1 Jan 15, 2024
5412711
chore: fix merge conflict
Gbogboade1 Jan 15, 2024
e033b53
chore: remove unusd code
Gbogboade1 Jan 15, 2024
ce2fa64
remove DS_Store file
gbogboadePush Jan 15, 2024
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
Binary file renamed test/.DS_Store → .DS_Store
Binary file not shown.
31 changes: 16 additions & 15 deletions example/demo_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ PODS:
- Flutter
- flutter_webrtc (0.9.36):
- Flutter
- WebRTC-SDK (= 114.5735.02)
- WebRTC-SDK (= 114.5735.08)
- image_cropper (0.0.4):
- Flutter
- TOCropViewController (~> 2.6.1)
- image_picker_ios (0.0.1):
- Flutter
- livekit_client (1.4.0):
- livekit_client (1.5.6):
- Flutter
- WebRTC-SDK (= 114.5735.02)
- WebRTC-SDK (= 114.5735.08)
- openpgp (0.6.0):
- Flutter
- path_provider_foundation (0.0.1):
Expand All @@ -29,7 +29,8 @@ PODS:
- TOCropViewController (2.6.1)
- video_player_avfoundation (0.0.1):
- Flutter
- WebRTC-SDK (114.5735.02)
- FlutterMacOS
- WebRTC-SDK (114.5735.08)

DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
Expand All @@ -43,7 +44,7 @@ DEPENDENCIES:
- openpgp (from `.symlinks/plugins/openpgp/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)

SPEC REPOS:
trunk:
Expand Down Expand Up @@ -75,24 +76,24 @@ EXTERNAL SOURCES:
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
video_player_avfoundation:
:path: ".symlinks/plugins/video_player_avfoundation/ios"
:path: ".symlinks/plugins/video_player_avfoundation/darwin"

SPEC CHECKSUMS:
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_image: 9c0b7451838484458e5b0fae007b86a4c2d4bdfe
flutter_webrtc: 1944895d4e908c4bc722929dc4b9f8620d8e1b2f
flutter_webrtc: 55df3aaa802114dad390191a46c2c8d535751268
image_cropper: a3291c624a953049bc6a02e1f8c8ceb162a24b25
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
livekit_client: dedfd6601bfb2c567d6988491c8bab7ceeb5a6d9
openpgp: 7d926bdb9e5544b1ae69a7a051716c36a3271b38
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
livekit_client: 381ed3cad6ba0b6ffbfffcf1b5db95ad1e61ffa2
openpgp: 117b855c299b1e74f9f58fc027adf456aaac09c2
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
WebRTC-SDK: dd913fd31cfbf1d43b9a22d83f4c6354c960c623
video_player_avfoundation: e9e6f9cae7d7a6d9b43519b0aab382bca60fcfd1
WebRTC-SDK: c24d2a6c9f571f2ed42297cb8ffba9557093142b

PODFILE CHECKSUM: f9420bd595da8fbce156b547dcd3368afc5226ff

Expand Down
2 changes: 1 addition & 1 deletion example/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 = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
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 = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/use_cases/lib/models/signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EthersSigner extends push.Signer {
privateKey: ethersWallet.privateKey, message: Uint8List.fromList(m));
return signature;
} catch (e) {
print('override: getEip191Signature: error$e');
push.log('override: getEip191Signature: error$e');
return message;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/push_restapi_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export 'src/payloads/payloads.dart';
export 'src/video/video.dart';
export 'src/sockets/sockets.dart';

export 'src/pushapi/__pushapi.dart';
export 'src/pushapi/pushapi.dart';
export 'src/pushstream/push_stream.dart';

export 'src/main.dart';
2 changes: 1 addition & 1 deletion lib/src/helpers/src/crypto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ Future<String> decryptPGPKey({
}

//TODO: Implement verifyProfileKeys
verifyProfileKeys({
verifyProfileKeys({
required String encryptedPrivateKey,
required String publicKey,
required String did,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/models/src/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ class AdditionalMeta {
}
}

class NotificationPayload {
class NotificationApiPayload {
NotificationOptions notification;
PayloadData data;
dynamic recipients;

NotificationPayload({
NotificationApiPayload({
required this.notification,
required this.data,
required this.recipients,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/payloads/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ String getUUID() {
return uuid.v4();
}

NotificationPayload? getPayloadForAPIInput(
NotificationApiPayload? getPayloadForAPIInput(
SendNotificationInputOptions inputOptions, dynamic recipients) {
if (inputOptions.notification != null && inputOptions.payload != null) {
return NotificationPayload(
return NotificationApiPayload(
notification: NotificationOptions(
title: inputOptions.notification?.title ?? '',
body: inputOptions.notification?.body ?? '',
Expand Down Expand Up @@ -117,7 +117,7 @@ Future<String> getVerificationProof({
required NOTIFICATION_TYPE notificationType,
required IDENTITY_TYPE identityType,
required String verifyingContract,
required NotificationPayload? payload,
required NotificationApiPayload? payload,
String? ipfsHash,
Map<String, dynamic> graph = const {},
required String uuid,
Expand Down Expand Up @@ -197,7 +197,7 @@ Future<String> getVerificationProof({

String getPayloadIdentity({
required IDENTITY_TYPE identityType,
required NotificationPayload? payload,
required NotificationApiPayload? payload,
NOTIFICATION_TYPE? notificationType,
String? ipfsHash,
Graph? graph,
Expand Down
4 changes: 0 additions & 4 deletions lib/src/pushapi/__pushapi.dart

This file was deleted.

121 changes: 4 additions & 117 deletions lib/src/pushapi/pushapi.dart
Original file line number Diff line number Diff line change
@@ -1,117 +1,4 @@
import '../../push_restapi_dart.dart';

class PushAPI {
late final Signer? _signer;
late final String _account;
late final String? _decryptedPgpPvtKey;
final String? pgpPublicKey;
final bool readMode;

void Function(ProgressHookType)? progressHook;

late Chat chat;
PushAPI({
Signer? signer,
required String account,
String? decryptedPgpPvtKey,
this.pgpPublicKey,
this.progressHook,
this.readMode = false,
ENV env = ENV.staging,
bool showHttpLog = false,
}) {
_signer = signer;
_account = account;
_decryptedPgpPvtKey = decryptedPgpPvtKey;

initPush(
env: env,
showHttpLog: showHttpLog,
);

chat = Chat(
signer: _signer,
account: _account,
decryptedPgpPvtKey: _decryptedPgpPvtKey,
pgpPublicKey: pgpPublicKey,
progressHook: progressHook,
);
}

static Future<PushAPI> initialize(
{Signer? signer, PushAPIInitializeOptions? options}) async {
if (signer == null && options?.account == null) {
throw Exception("Either 'signer' or 'account' must be provided.");
}

final readMode = signer != null;

// Get account
// Derives account from signer if not provided
String? derivedAccount;

if (signer != null) {
derivedAccount = getAccountAddress(
getWallet(address: options?.account, signer: signer));
} else {
derivedAccount = options?.account;
}

if (derivedAccount == null) {
throw Exception('Account could not be derived.');
}

String? decryptedPGPPrivateKey;
String? pgpPublicKey;

/**
* Decrypt PGP private key
* If user exists, decrypts the PGP private key
* If user does not exist, creates a new user and returns the decrypted PGP private key
*/
final user = await getUser(address: derivedAccount);

if (readMode) {
if (user != null && user.encryptedPrivateKey != null) {
decryptedPGPPrivateKey = await decryptPGPKey(
toUpgrade: options?.autoUpgrade,
progressHook: options?.progressHook,
additionalMeta: options?.versionMeta,
encryptedPGPPrivateKey: user.encryptedPrivateKey!,
wallet: getWallet(address: options?.account, signer: signer),
);
pgpPublicKey = user.publicKey;
} else {
final newUser = await createUser(
signer: signer,
progressHook: options?.progressHook ?? (_) {},
version: options?.version ?? ENCRYPTION_TYPE.PGP_V3,
);
decryptedPGPPrivateKey = newUser.decryptedPrivateKey;
pgpPublicKey = newUser.publicKey;
}
}

final api = PushAPI(
account: derivedAccount,
signer: signer,
decryptedPgpPvtKey: decryptedPGPPrivateKey,
pgpPublicKey: pgpPublicKey,
readMode: readMode,
showHttpLog: options?.showHttpLog ?? false,
);

return api;
}

//TODO initStream
Future initStream() async {}

Future<User?> info({String? overrideAccount}) async {
return getUser(address: overrideAccount ?? _account);
}

static String ensureSignerMessage() {
return 'Operation not allowed in read-only mode. Signer is required.';
}
}
export 'src/models.dart';
export 'src/pushapi.dart';
export 'src/chat.dart' hide GroupAPI, GroupParticipantsAPI;
export 'src/user.dart';
6 changes: 3 additions & 3 deletions lib/src/pushapi/chat.dart → lib/src/pushapi/src/chat.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ignore_for_file: library_prefixes

import '../../push_restapi_dart.dart';
import '../chat/chat.dart' as PUSH_CHAT;
import '../user/user.dart' as PUSH_USER;
import '../../../push_restapi_dart.dart';
import '../../chat/chat.dart' as PUSH_CHAT;
import '../../user/user.dart' as PUSH_USER;

class Chat {
late final Signer? _signer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ignore_for_file: constant_identifier_names

import '../../push_restapi_dart.dart';
import '../../../push_restapi_dart.dart';

class PushAPIInitializeOptions {
void Function(ProgressHookType)? progressHook;
Expand Down
Loading