Skip to content

Commit

Permalink
SDK Version 2.4.0 (#53)
Browse files Browse the repository at this point in the history
Breaking Changes:
* `DMEClientDelegate` has been split out into `DMEClientAuthorizationDelegate` and `DMEClientDownloadDelegate`.

New features:

* Clients can now limit authorization request to include only data for a specified time range.
* Client can now return data in encrypted form.
* Experimental Repository subspec which provides a more intuitive way of using and querying native objects. Initially available with Social (Post, Media, Comment), Finance (Transaction) and Government (UK Vehicle Registration and MOT Tests) objects.  More will be added in future.

Better error handling:

* Add ability to stop supporting older versions of the SDK in the future.  When an SDK is no longer supported, a new error `SDKErrorInvalidVersion` will be returned during session creation. 
* Also performed a tidy up of errors being returned - some were being returned to caller via delegate and not via completion block - this is now consistent.
* Notify developer if they fail to set the callback URL scheme in the Info.plist via new `SDKErrorNoURLScheme` error.

Getting ready for upcoming features:

* Add support for future Guest Consent authorization.
* Add support for future ability to request a Postbox identifier.
  • Loading branch information
alex-yushchenko authored and michaeleustace committed Dec 17, 2018
1 parent 6c9f1eb commit 567cc71
Show file tree
Hide file tree
Showing 266 changed files with 10,450 additions and 5,879 deletions.
3 changes: 2 additions & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Carthage
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
# Pods/
Pods/
Podfile.lock
Empty file modified .swift-version
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
32 changes: 27 additions & 5 deletions DigiMeSDK.podspec
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
Pod::Spec.new do |s|

s.name = "DigiMeSDK"
s.version = "2.1.1"
s.version = "2.4.0"
s.summary = "digi.me iOS Consent Access SDK"
s.homepage = "https://github.com/digime/digime-sdk-ios"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "digi.me Ltd." => "ios@digi.me" }
s.platform = :ios, "10.0"
s.source = { :git => "https://github.com/digime/digime-sdk-ios.git", :branch => "#{s.version}", :tag => "#{s.version}" }
s.source_files = "DigiMeSDK/**/*.{h,m}"
s.frameworks = "Foundation", "UIKit", "CoreGraphics", "Security", "StoreKit"
s.resources = ["DigiMeSDK/Assets/*.{der}"]
s.dependency "Brotli"

s.source = {
:git => "https://github.com/digime/digime-sdk-ios.git",
:branch => s.version,
:tag => s.version
}

s.default_subspec = 'Core'

s.subspec 'Core' do |ss|
ss.source_files = "DigiMeSDK/Core/Classes/**/*.{h,m}", "DigiMeSDK/DigiMeSDK.h"
ss.resources = ["DigiMeSDK/Core/Assets/*.{der}"]
ss.frameworks = "Foundation", "UIKit", "CoreGraphics", "Security", "StoreKit"
ss.private_header_files = 'DigiMeSDK/Core/Classes/Network/*.h',
'DigiMeSDK/Core/Classes/Utility/*.h',
'DigiMeSDK/Core/Classes/Security/DME*.h',
'DigiMeSDK/Core/Classes/DMEAuthorizationManager.h',
'DigiMeSDK/Core/Classes/DMEClient+Private.h'
end


s.subspec 'Repository' do |ss|
ss.source_files = "DigiMeSDK/Repository/Classes/**/*.swift"
ss.frameworks = "Foundation"
ss.dependency "DigiMeSDK/Core"
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 13 additions & 3 deletions DigiMeSDK/Core/CASessionManager.h → DigiMeSDK/Core/Classes/CASessionManager.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,35 @@
// DigiMeSDK
//
// Created on 29/01/2018.
// Copyright © 2018 DigiMe. All rights reserved.
// Copyright © 2018 digi.me Limited. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DMEClientCallbacks.h"
#import "CASession.h"

NS_ASSUME_NONNULL_BEGIN

@class DMEAPIClient;
@class DMEClient;

@interface CASessionManager : NSObject

@property (nonatomic, strong, readonly) CASession *currentSession;
@property (nonatomic, strong, nullable, readonly) CASession *currentSession;

@property (nonatomic, strong, nullable, readonly) id<CADataRequest> scope;

@property (nonatomic, strong, readonly) DMEClient *client;

- (instancetype)initWithApiClient:(DMEAPIClient *)apiClient;

/**
Will return session object. Either existing session will be re-used, or new session will be created.
@param scope optional CADataRequest that sets scope filter for the session.
@param completion AuthorizationCompletionBlock
*/
- (void)sessionWithCompletion:(AuthorizationCompletionBlock)completion;
- (void)sessionWithScope:(nullable id<CADataRequest>)scope completion:(AuthorizationCompletionBlock)completion;


/**
Expand All @@ -43,3 +51,5 @@
- (BOOL)isSessionKeyValid:(NSString *)sessionKey;

@end

NS_ASSUME_NONNULL_END
56 changes: 20 additions & 36 deletions DigiMeSDK/Core/CASessionManager.m → DigiMeSDK/Core/Classes/CASessionManager.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// DigiMeSDK
//
// Created on 29/01/2018.
// Copyright © 2018 DigiMe. All rights reserved.
// Copyright © 2018 digi.me Limited. All rights reserved.
//

#import "CASessionManager.h"
#import "DMECryptoUtilities.h"
#import "DMEAPIClient.h"
#import "CASessionDeserializer.h"
#import "DMEClient.h"
#import "DMEClient+Private.h"

@interface CASessionManager()

Expand All @@ -23,45 +23,34 @@ @implementation CASessionManager

#pragma mark - Public

- (void)sessionWithCompletion:(AuthorizationCompletionBlock)completion
- (instancetype)initWithApiClient:(DMEAPIClient *)apiClient
{
//validation
if (!self.client.contractId)
self = [super init];
if (self)
{
completion(nil, [NSError sdkError:SDKErrorNoContract]);
return;
}

if (![DMECryptoUtilities validateContractId:self.client.contractId])
{
completion(nil, [NSError sdkError:SDKErrorInvalidContract]);
return;
_apiClient = apiClient;
}

return self;
}

- (void)sessionWithScope:(id<CADataRequest>)scope completion:(AuthorizationCompletionBlock)completion
{
//create new session. We always retrieve new session when requesting authorization
[self invalidateCurrentSession];

[self.apiClient requestSessionWithSuccess:^(NSData * _Nonnull data) {
[self.apiClient requestSessionWithScope:scope success:^(NSData * _Nonnull data) {

NSError *error;
CASession *session = [CASessionDeserializer deserialize:data error:&error];

self.currentSession = session;

if (session)
{
dispatch_async(dispatch_get_main_queue(), ^{
if ([self.client.delegate respondsToSelector:@selector(sessionCreated:)])
{
[self.client.delegate sessionCreated:session];
}
});
}
else if (error)
if (error != nil)
{
NSLog(@"[CASessionManager] Failed to create session: %@", error.localizedDescription);
}
else
else if (session == nil)
{
//something unknown occurred.
error = [NSError authError:AuthErrorGeneral];
Expand All @@ -71,13 +60,12 @@ - (void)sessionWithCompletion:(AuthorizationCompletionBlock)completion

} failure:^(NSError * _Nonnull error) {

if ([self.client.delegate respondsToSelector:@selector(sessionCreateFailed:)])
if (error.code == 403 && [error.userInfo[@"code"] isEqualToString:@"SDKVersionInvalid"])
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.client.delegate sessionCreateFailed:error];
});
completion(nil, [NSError sdkError:SDKErrorInvalidVersion]);
return;
}

completion(nil, error);
}];
}
Expand All @@ -88,7 +76,8 @@ - (BOOL)isSessionValid
{
return (self.currentSession && self.currentSession.expiryDate && [self.currentSession.expiryDate compare:[NSDate date]] == NSOrderedDescending && [self.currentSession.sessionId isEqualToString:self.client.contractId]);
}
-(BOOL)isSessionKeyValid:(NSString *)sessionKey

- (BOOL)isSessionKeyValid:(NSString *)sessionKey
{
return (sessionKey.length > 0 && [sessionKey isEqualToString:self.currentSession.sessionKey]);
}
Expand All @@ -105,9 +94,4 @@ - (DMEClient *)client
return [DMEClient sharedClient];
}

- (DMEAPIClient *)apiClient
{
return self.client.apiClient;
}

@end
64 changes: 64 additions & 0 deletions DigiMeSDK/Core/Classes/Callbacks/DMEClientAuthorizationDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// DMEClientAuthorizationDelegate.h
// DigiMeSDK
//
// Created on 09/07/2018.
// Copyright © 2018 digi.me Limited. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CASession.h"
#import "NSError+SDK.h"
#import "NSError+Auth.h"
#import "NSError+API.h"

#pragma once

NS_ASSUME_NONNULL_BEGIN

@protocol DMEClientAuthorizationDelegate <NSObject>

@optional

/**
Executed when session has been created.
@param session Consent Access Session
*/
- (void)sessionCreated:(CASession *)session;


/**
Executed when session creation has failed.
@param error NSError
*/
- (void)sessionCreateFailed:(NSError *)error;


/**
Executed when CA Contract has been successfully authorized.
@param session Consent Access Session
*/
- (void)authorizeSucceeded:(CASession *)session;


/**
Executed when CA Contract has been declined by the user.
@param error NSError
*/
- (void)authorizeDenied:(NSError *)error;


/**
Executed when CA Contract has been authorized, but failed for another reason.
@param error NSError
*/
- (void)authorizeFailed:(NSError *)error;

@end

NS_ASSUME_NONNULL_END
12 changes: 10 additions & 2 deletions DigiMeSDK/Callbacks/DMEClientCallbacks.h → ...re/Classes/Callbacks/DMEClientCallbacks.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// DigiMeSDK
//
// Created on 29/01/2018.
// Copyright © 2018 DigiMe. All rights reserved.
// Copyright © 2018 digi.me Limited. All rights reserved.
//

#import "CASession.h"
Expand All @@ -13,8 +13,9 @@

#pragma once

NS_ASSUME_NONNULL_BEGIN
@class CAPostbox;

NS_ASSUME_NONNULL_BEGIN

/**
AuthorizationCompletionBlock - executed when authorization stage has completed.
Expand All @@ -24,6 +25,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
typedef void (^AuthorizationCompletionBlock) (CASession * _Nullable session, NSError * _Nullable error);

/**
PostboxCompletionBlock - executed when a Postbox is retrieved.
@param postbox CAPostbox
@param error NSError
*/
typedef void (^PostboxCreationCompletionBlock) (CAPostbox * _Nullable postbox, NSError * _Nullable error);

/**
FileListCompletionBlock - executed when file list has been retrieved.
Expand Down
Loading

0 comments on commit 567cc71

Please sign in to comment.