Skip to content

Commit

Permalink
Merge pull request #32 from Keyri-Co/releases/1.8.0
Browse files Browse the repository at this point in the history
Updated iOS SDK to 4.6.0-alpha04, updated Android SDK to 4.3.0-alpha0…
  • Loading branch information
AndrewKuliahin96 authored Mar 27, 2024
2 parents f1c4e4a + e2f05dd commit 6d3f81d
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.8.0

- Updated iOS SDK
to [4.6.0-alpha04](https://github.com/Keyri-Co/keyri-ios-whitelabel-sdk/releases/tag/4.6.0-alpha04)
- Updated Android SDK
to [4.3.0-alpha05](https://github.com/Keyri-Co/keyri-android-whitelabel-sdk/releases/tag/4.3.0-alpha05)
- Fixed Keyri timestamps
- Added `getCorrectedTimestampSeconds` method which checks time changes and get corrected NTP
timestamp

## 1.7.2

- Fixed `sendEvent` issue on Android
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {

dependencies {
// Keyri
implementation 'com.keyri:keyrisdk:4.2.4'
implementation 'com.keyri:scanner:4.2.4'
implementation 'com.keyri:keyrisdk:4.3.0-alpha05'
implementation 'com.keyri:scanner:4.3.0-alpha05'

// Gson
implementation 'com.google.code.gson:gson:2.10.1'
Expand Down
47 changes: 43 additions & 4 deletions android/src/main/kotlin/com/keyrico/keyri/KeyriPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,26 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
val appKey = arguments?.get("appKey")
val publicApiKey = arguments?.get("publicApiKey")
val serviceEncryptionKey = arguments?.get("serviceEncryptionKey")
val blockEmulatorDetection =
arguments?.get("blockEmulatorDetection")?.toBoolean() ?: true
val blockEmulatorDetection: Boolean = arguments?.get("blockEmulatorDetection")?.toBoolean() ?: true
// val blockRootDetection: Boolean = arguments?.get("blockRootDetection")?.toBoolean() ?: false
// val blockDangerousAppsDetection: Boolean = arguments?.get("blockDangerousAppsDetection")?.toBoolean() ?: false

// TODO: Uncommnet when available
// val blockTamperDetection: Boolean = arguments?.get("blockTamperDetection")?.toBoolean() ?: true
// val blockTamperDetection: Boolean = true

// val blockSwizzleDetection: Boolean = arguments?.get("blockSwizzleDetection")?.toBoolean() ?: false

logMessage("Keyri: initialize called")
initialize(
appKey,
publicApiKey,
serviceEncryptionKey,
blockEmulatorDetection,
// blockRootDetection,
// blockDangerousAppsDetection,
// blockTamperDetection,
// blockSwizzleDetection
result
)
}
Expand Down Expand Up @@ -164,6 +175,11 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
register(publicUserId, result)
}

"getCorrectedTimestampSeconds" -> {
logMessage("Keyri: getCorrectedTimestampSeconds called")
getCorrectedTimestampSeconds(result)
}

"initializeDefaultConfirmationScreen" -> {
logMessage("Keyri: initializeDefaultConfirmationScreen called")
initializeDefaultConfirmationScreen(arguments?.get("payload"), result)
Expand Down Expand Up @@ -227,6 +243,10 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
publicApiKey: String?,
serviceEncryptionKey: String?,
blockEmulatorDetection: Boolean,
// blockRootDetection: Boolean,
// blockDangerousAppsDetection: Boolean,
// blockTamperDetection: Boolean,
// blockSwizzleDetection: Boolean,
result: MethodChannel.Result
) {
if (appKey == null) {
Expand All @@ -241,6 +261,14 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
publicApiKey,
serviceEncryptionKey,
blockEmulatorDetection
// TODO: Add impl
// KeyriDetectionsConfig(
// blockEmulatorDetection,
// false,
// false,
// true,
// false,
// )
)
}

Expand Down Expand Up @@ -273,9 +301,11 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
appKey,
publicApiKey,
serviceEncryptionKey,
blockEmulatorDetection,
// TODO: Add impl
// blockEmulatorDetection,
payload,
publicUserId
publicUserId,
// detectionsConfig = KeyriDetectionsConfig()
)

easyKeyriAuthResult = result
Expand Down Expand Up @@ -467,6 +497,15 @@ class KeyriPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}

private fun getCorrectedTimestampSeconds(result: MethodChannel.Result) {
keyriCoroutineScope("getCorrectedTimestampSeconds", result::error).launch {
val correctedTimestampSeconds = keyri.getCorrectedTimestampSeconds()

logMessage("Keyri getCorrectedTimestampSeconds: $correctedTimestampSeconds")
result.success(correctedTimestampSeconds)
}
}

private fun initializeDefaultConfirmationScreen(
payload: String?,
result: MethodChannel.Result
Expand Down
18 changes: 18 additions & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
33A10266DE373D3FFFE9596F /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -196,6 +197,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
33A10266DE373D3FFFE9596F /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down
18 changes: 18 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class _KeyriHomePageState extends State<KeyriHomePage> {
button(_sendEvent, 'Send event'),
button(_login, 'Login'),
button(_register, 'Register'),
button(_getCorrectedTimestampSeconds, 'Get timestamp'),
button(_generateAssociationKey, 'Generate association key'),
button(_getAssociationKey, 'Get association key'),
button(_removeAssociationKey, 'Remove association key'),
Expand Down Expand Up @@ -168,6 +169,23 @@ class _KeyriHomePageState extends State<KeyriHomePage> {
.catchError((error, stackTrace) => _processError(error));
}

Future<void> _getCorrectedTimestampSeconds() async {
Keyri? keyri = initKeyri();

if (keyri == null) return;

String? publicUserId = usernameController.text;

if (publicUserId.isEmpty) {
publicUserId = null;
}

keyri
.getCorrectedTimestampSeconds()
.then((timestamp) => _showMessage('Timestamp: $timestamp'))
.catchError((error, stackTrace) => _processError(error));
}

void _generateAssociationKey() {
Keyri? keyri = initKeyri();

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: keyri_example
version: 1.7.2
version: 1.8.0
description: Demonstrates how to use the Keyri plugin.
publish_to: 'none'

Expand Down
20 changes: 20 additions & 0 deletions ios/Classes/KeyriPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
[self login:call result:result];
} else if ([@"register" isEqualToString:call.method]) {
[self register:call result:result];
} else if ([@"getCorrectedTimestampSeconds" isEqualToString:call.method]) {
[self getCorrectedTimestampSeconds:call result:result];
} else if ([@"initializeDefaultConfirmationScreen" isEqualToString:call.method]) {
[self initializeDefaultConfirmationScreen:call result:result];
} else if ([@"processLink" isEqualToString:call.method]) {
Expand All @@ -71,6 +73,11 @@ - (void)initialize:(FlutterMethodCall*)call result:(FlutterResult)result {
id publicApiKeyValue = call.arguments[@"publicApiKey"];
id serviceEncryptionKeyValue = call.arguments[@"serviceEncryptionKey"];
id blockEmulatorDetectionValue = call.arguments[@"blockEmulatorDetection"];
// TODO: Uncomment and add implementation
// id blockRootDetection = call.arguments[@"blockRootDetection"];
// id blockDangerousAppsDetection = call.arguments[@"blockDangerousAppsDetection"];
// id blockTamperDetection = call.arguments[@"blockTamperDetection"];
// id blockSwizzleDetection = call.arguments[@"blockSwizzleDetection"];

if (appKey == nil || ![appKey isKindOfClass:[NSString class]]) {
return [self sendErrorResult:result errorMessage:@"You need to provide appKey"];
Expand All @@ -85,6 +92,11 @@ - (void)initialize:(FlutterMethodCall*)call result:(FlutterResult)result {
NSString *publicApiKey = [publicApiKeyValue isKindOfClass:[NSString class]] ? publicApiKeyValue : nil;
NSString *serviceEncryptionKey = [serviceEncryptionKeyValue isKindOfClass:[NSString class]] ? serviceEncryptionKeyValue : nil;

// TODO: Add impl
// KeyriDetectionsConfig *config = [[KeyriDetectionsConfig alloc] initWithBlockEmulatorDetection: blockEmulatorDetection blockRootDetection:blockRootDetection blockDangerousAppsDetection:blockDangerousAppsDetection blockTamperDetection:blockTamperDetection blockSwizzleDetection:blockSwizzleDetection];
//
// self.keyri = [[KeyriObjC alloc] initWithAppKey:appKey publicApiKey:publicApiKey serviceEncryptionKey:serviceEncryptionKey detectionsConfig:config];

[self.keyri initializeKeyriWithAppKey:appKey publicApiKey:publicApiKey serviceEncryptionKey:serviceEncryptionKey blockEmulatorDetection:blockEmulatorDetection];
result(@(YES));
}
Expand Down Expand Up @@ -296,6 +308,14 @@ - (void)register:(FlutterMethodCall*)call result:(FlutterResult)result {
}];
}

- (void)getCorrectedTimestampSeconds:(FlutterMethodCall*)call result:(FlutterResult)result {
[self.keyri getCorrectedTimestampSecondsWithPubUserd:@"publicUserId" completion:^(double timestamp) {
NSInteger timeInSeconds = (NSInteger)ceil(timestamp);

return result(@(timeInSeconds));
}];
}

- (void)initializeDefaultConfirmationScreen:(FlutterMethodCall*)call result:(FlutterResult)result {
id payload = call.arguments[@"payload"];

Expand Down
2 changes: 1 addition & 1 deletion ios/keyri_v3.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pod::Spec.new do |spec|
spec.public_header_files = 'Classes/**/*.h'

spec.dependency 'Flutter'
spec.dependency 'keyri-pod', '~> 4.5.1'
spec.dependency 'keyri-pod', '~> 4.6.0-alpha04'

# Flutter.framework does not contain a i386 slice.
spec.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
6 changes: 6 additions & 0 deletions lib/keyri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class Keyri {
return KeyriPlatform.instance.register(publicUserId);
}

/// Call it to get timestamp synchronized with NTP.
/// Returns Future of [Long] object or error.
Future<int> getCorrectedTimestampSeconds() {
return KeyriPlatform.instance.getCorrectedTimestampSeconds();
}

/// Call it to show Confirmation screen with default UI.
Future<bool> initializeDefaultConfirmationScreen(String payload) {
return KeyriPlatform.instance.initializeDefaultConfirmationScreen(payload);
Expand Down
5 changes: 5 additions & 0 deletions lib/src/keyri_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ class MethodChannelKeyri extends KeyriPlatform {
return RegisterObject.fromJson(registerObject);
}

@override
Future<int> getCorrectedTimestampSeconds() async {
return await methodChannel.invokeMethod('getCorrectedTimestampSeconds');
}

@override
Future<bool> initializeDefaultConfirmationScreen(String payload) async {
return await methodChannel.invokeMethod<bool>(
Expand Down
4 changes: 4 additions & 0 deletions lib/src/keyri_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ abstract class KeyriPlatform extends PlatformInterface {
throw UnimplementedError('register() has not been implemented.');
}

Future<int> getCorrectedTimestampSeconds() {
throw UnimplementedError('getCorrectedTimestampSeconds() has not been implemented.');
}

Future<bool> initializeDefaultConfirmationScreen(String payload) {
throw UnimplementedError(
'initializeDefaultConfirmationScreen() has not been implemented.');
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: keyri_v3
description: Keyri QR Login plugin for Flutter. Provides Keyri SDK capabilities for secure and passwordless login.
version: 1.7.2
version: 1.8.0
homepage: https://keyri.com

environment:
Expand Down

0 comments on commit 6d3f81d

Please sign in to comment.