Skip to content

Commit

Permalink
Develop -> cordova (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
kober32 authored Sep 11, 2024
1 parent 718e2ef commit 0bc73ac
Show file tree
Hide file tree
Showing 30 changed files with 402 additions and 371 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ repositories {
}

dependencies {
api "com.wultra.android.powerauth:powerauth-sdk:1.7.8"
api "com.wultra.android.powerauth:powerauth-sdk:1.7.9"

if (project == rootProject) {
// The standalone build require to specify exact version of RN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void isConfigured(@Nonnull String instanceId, final Promise promise) {
}

@ReactMethod
public void configure(final String instanceId, final ReadableMap configuration, final ReadableMap clientConfiguration, final ReadableMap biometryConfiguration, final ReadableMap keychainConfiguration, final Promise promise) {
public void configure(final String instanceId, final ReadableMap configuration, final ReadableMap clientConfiguration, final ReadableMap biometryConfiguration, final ReadableMap keychainConfiguration, final ReadableMap sharingConfiguration, Promise promise) {
try {
boolean result = registerPowerAuthInstance(instanceId, () -> {
// Create configurations from maps
Expand Down Expand Up @@ -288,6 +288,12 @@ public void run(@NonNull PowerAuthSDK sdk) {
});
}

@ReactMethod
public void getExternalPendingOperation(String instanceId, final Promise promise) {
// Not supported on Android
promise.resolve(null);
}

@ReactMethod
public void fetchActivationStatus(String instanceId, final Promise promise) {
final Context context = this.context;
Expand Down
18 changes: 17 additions & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ In case that you need an advanced configuration, then you can import and use the
- `userDefaultsSuiteName` - iOS specific, defines suite name used by the `UserDefaults` that check for Keychain data presence. This is useful in situations, when your application is sharing data with another application or application's extension from the same vendor. The default value is `null`. See note<sup>2</sup> below.
- `minimalRequiredKeychainProtection` - Android specific, defines minimal required keychain protection level that must be supported on the current device. The default value is `PowerAuthKeychainProtection.NONE`. See note<sup>3</sup> below.

- `PowerAuthSharingConfiguration` class or `PowerAuthSharingConfigurationType` interface - to configure an activation data sharing on iOS platform. You can alter the following parameters:
- `appGroup` - defines name of app group that allows you sharing data between multiple applications. Be aware that the value overrides `accessGroupName` property if it's provided in `PowerAuthKeychainConfiguration`.
- `appIdentifier`- defines unique application identifier. This identifier helps you to determine which application currently holds the lock on activation data in a special operations.
- `keychainAccessGroup` - defines keychain access group name used by the PowerAuthSDK keychain instances.
- `sharedMemoryIdentifier` - defines optional identifier of memory shared between the applications in app group. If identifier is not provided then PowerAuthSDK calculate unique identifier based on `PowerAuth.instanceId`.
- If you're not familiar with sharing data between iOS applications, or app extensions, then please refer the native PowerAuth mobile SDK documentation, where this topic is explained in more detail.


> Note 1: Setting `authenticateOnBiometricKeySetup` parameter to `true` leads to use symmetric AES cipher on the background so both configuration and usage of biometric key require the biometric authentication. If set to `false`, then RSA cipher is used and only the usage of biometric key require the biometric authentication. This is due to fact, that RSA cipher can encrypt data with using it's public key available immediate after the key-pair is created in Android KeyStore.
> Note 2: You're responsible to migrate the keychain and `UserDefaults` data from non-shared storage to the shared one, before you configure the first `PowerAuth` instance. This is quite difficult to do in JavaScript, so it's recommended to do not alter `PowerAuthKeychainConfiguration` once your application is already shipped in AppStore.
Expand Down Expand Up @@ -100,7 +108,15 @@ export default class AppMyApplication extends Component {
const clientConfiguration = { enableUnsecureTraffic: false };
const biometryConfiguration = { linkItemsToCurrentSet: true };
const keychainConfiguration = { minimalRequiredKeychainProtection: PowerAuthKeychainProtection.SOFTWARE };
await this.powerAuth.configure(configuration, clientConfiguration, biometryConfiguration, keychainConfiguration);
const sharingConfiguration = {
// This is iOS specific. All values will be ignored on Android platform.
// All the following values are fake. Please read a native PowerAuth mobile SDK documentation
// about activation data sharing that explains how to prepare parameters in detail.
appGroup: "group.your.app.group",
appIdentifier: "some.identifier",
keychainAccessGroup: "keychain.access.group"
};
await this.powerAuth.configure(configuration, clientConfiguration, biometryConfiguration, keychainConfiguration, sharingConfiguration);
console.log("PowerAuth configuration successfull.");
} catch(e) {
console.log(`PowerAuth failed to configure: ${e.code}`);
Expand Down
5 changes: 4 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const tmpDir = ".build";
// TODO: extract from the code
const objectsToExport = [
"PowerAuth",
"PowerAuthError",
"PowerAuthActivation",
"PowerAuthAuthentication",
"PowerAuthActivationCodeUtil",
Expand All @@ -151,19 +152,21 @@ const tmpDir = ".build";
"PowerAuthActivationState",
"PowerAuthBiometryConfiguration",
"PowerAuthBiometryStatus",
"PowerAuthBiometryType",
"PowerAuthClientConfiguration",
"PowerAuthConfiguration",
"PowerAuthError",
"PowerAuthErrorCode",
"PowerAuthKeychainConfiguration",
"PowerAuthKeychainProtection",
"PowerAuthSharingConfiguration",
"PowerAuthPassword",
"BaseNativeObject",
"PinTestIssue",
"buildConfiguration",
"buildClientConfiguration",
"buildBiometryConfiguration",
"buildKeychainConfiguration",
"buildSharingConfiguration",
"PowerAuthDebug",
"NativeObjectRegister",
]
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target 'PowerAuth' do
:path => config[:reactNativePath],
:hermes_enabled => false
)
pod 'PowerAuth2', '~> 1.7.8'
pod 'PowerAuth2', '~> 1.7.9'
# Uncomment to use not-published SDK in project. This is effective only if you manually open 'ios/PowerAuth.xcworkspace'
#pod 'PowerAuth2', :git => 'https://github.com/wultra/powerauth-mobile-sdk.git', :branch => 'develop', :submodules => true
end
28 changes: 27 additions & 1 deletion ios/PowerAuth/PowerAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ + (BOOL) requiresMainQueueSetup
PAJS_ARGUMENT(configuration, NSDictionary*)
PAJS_ARGUMENT(clientConfiguration, NSDictionary*)
PAJS_ARGUMENT(biometryConfiguration, NSDictionary*)
PAJS_ARGUMENT(keychainConfiguration, NSDictionary*))
PAJS_ARGUMENT(keychainConfiguration, NSDictionary*)
PAJS_ARGUMENT(sharingConfiguration, NSDictionary*))
{
if (![self validateInstanceId:instanceId reject:reject]) {
return;
Expand All @@ -82,6 +83,14 @@ + (BOOL) requiresMainQueueSetup
config.appSecret = CAST_TO(configuration[@"applicationSecret"], NSString);
config.masterServerPublicKey = CAST_TO(configuration[@"masterServerPublicKey"], NSString);
config.baseEndpointUrl = CAST_TO(configuration[@"baseEndpointUrl"], NSString);
// Prepare sharing configuration
if (CAST_TO(sharingConfiguration[@"isProvided"], NSNumber).boolValue) {
PowerAuthSharingConfiguration * sharingConfig = [[PowerAuthSharingConfiguration alloc] initWithAppGroup:CAST_TO(sharingConfiguration[@"appGroup"], NSString)
appIdentifier:CAST_TO(sharingConfiguration[@"appIdentifier"], NSString)
keychainAccessGroup:CAST_TO(sharingConfiguration[@"keychainAccessGroup"], NSString)];
sharingConfig.sharedMemoryIdentifier = CAST_TO(sharingConfiguration[@"sharedMemoryIdentifier"], NSString);
config.sharingConfiguration = sharingConfig;
}

if (![config validateConfiguration]) {
reject(EC_WRONG_PARAMETER, @"Provided configuration is invalid", nil);
Expand Down Expand Up @@ -182,6 +191,23 @@ + (BOOL) requiresMainQueueSetup
}
PAJS_METHOD_END

PAJS_METHOD_START(getExternalPendingOperation,
PAJS_ARGUMENT(instanceId, NSString*))
{
PA_BLOCK_START
PowerAuthExternalPendingOperation * pendingOperation = powerAuth.externalPendingOperation;
if (pendingOperation) {
resolve(@{
@"externalOperationType": pendingOperation.externalOperationType == PowerAuthExternalPendingOperationType_Activation ? @"ACTIVATION" : @"PROTOCOL_UPGRADE",
@"externalApplicationId": pendingOperation.externalApplicationId
});
} else {
resolve(nil);
}
PA_BLOCK_END
}
PAJS_METHOD_END

PAJS_METHOD_START(fetchActivationStatus,
PAJS_ARGUMENT(instanceId, NSString*))
{
Expand Down
35 changes: 0 additions & 35 deletions other-platforms-support/cordova/ios/PowerAuth/RCTConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,12 @@ RCT_EXTERN void RCTSetDefaultColorSpace(RCTColorSpace colorSpace);
+ (NSTimeZone *)NSTimeZone:(id)json;
+ (NSTimeInterval)NSTimeInterval:(id)json;

+ (NSLineBreakMode)NSLineBreakMode:(id)json;
+ (NSTextAlignment)NSTextAlignment:(id)json;
+ (NSUnderlineStyle)NSUnderlineStyle:(id)json;
+ (NSWritingDirection)NSWritingDirection:(id)json;
+ (NSLineBreakStrategy)NSLineBreakStrategy:(id)json;
+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json;
+ (UITextFieldViewMode)UITextFieldViewMode:(id)json;
+ (UIKeyboardType)UIKeyboardType:(id)json;
+ (UIKeyboardAppearance)UIKeyboardAppearance:(id)json;
+ (UIReturnKeyType)UIReturnKeyType:(id)json;
+ (UIUserInterfaceStyle)UIUserInterfaceStyle:(id)json API_AVAILABLE(ios(12));
+ (UIInterfaceOrientationMask)UIInterfaceOrientationMask:(NSString *)orientation;
+ (UIModalPresentationStyle)UIModalPresentationStyle:(id)json;

#if !TARGET_OS_TV
+ (UIDataDetectorTypes)UIDataDetectorTypes:(id)json;
#endif

+ (UIViewContentMode)UIViewContentMode:(id)json;

+ (CGFloat)CGFloat:(id)json;
+ (CGPoint)CGPoint:(id)json;
+ (CGSize)CGSize:(id)json;
+ (CGRect)CGRect:(id)json;
+ (UIEdgeInsets)UIEdgeInsets:(id)json;

+ (CGLineCap)CGLineCap:(id)json;
+ (CGLineJoin)CGLineJoin:(id)json;

+ (CGAffineTransform)CGAffineTransform:(id)json;

+ (NSArray<NSArray *> *)NSArrayArray:(id)json;
+ (NSArray<NSString *> *)NSStringArray:(id)json;
+ (NSArray<NSArray<NSString *> *> *)NSStringArrayArray:(id)json;
+ (NSArray<NSDictionary *> *)NSDictionaryArray:(id)json;
+ (NSArray<NSURL *> *)NSURLArray:(id)json;
+ (NSArray<NSNumber *> *)NSNumberArray:(id)json;

typedef NSArray CGColorArray;
+ (CGColorArray *)CGColorArray:(id)json;

/**
* Convert a JSON object to a Plist-safe equivalent by stripping null values.
*/
Expand Down
Loading

0 comments on commit 0bc73ac

Please sign in to comment.