Skip to content

Commit

Permalink
Merge pull request #9 from thevixac/master
Browse files Browse the repository at this point in the history
Token Auth and cryptography fixes and renaming
  • Loading branch information
mattheworiordan committed Apr 29, 2015
2 parents be670f5 + c406df7 commit 28ada7b
Show file tree
Hide file tree
Showing 52 changed files with 1,002 additions and 621 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

An iOS client library for [ably.io](https://www.ably.io), the realtime messaging service, written in Objective-C.

## Installation
## CocoaPod Installation
add pod ably to your Podfile. While ably-ios is in development, use this line instead:
* pod "ably", :git => 'https://github.com/thevixac/ably-ios.git', :commit => 'be670f5e6c3'

## Manual Installation

* git clone https://github.com/ably/ably-ios
* drag the directory ably-ios/ably-ios into your project as a group
* git clone https://github.com/square/SocketRocket.git
* drag the directory SocketRocket/SocketRocket into your project as a group



## Using the Realtime API

### Connection
Expand Down Expand Up @@ -106,14 +108,10 @@ The library works on iOS8, and uses [SocketRocket](https://github.com/square/Soc
The following features are not implemented yet:

* msgpack transportation
* 256 cryptography

The following features are do not have sufficient test coverage:

* 128 cryptography
* app stats
* capability
* token auth

## Support and feedback

Expand Down
36 changes: 22 additions & 14 deletions ably-ios/ARTAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,44 @@

@class ARTRest;

@interface ARTAuthToken : NSObject
@interface ARTTokenDetails : NSObject

@property (readonly, strong, nonatomic) NSString *id;
@property (readonly, strong, nonatomic) NSString *token;
@property (readonly, assign, nonatomic) int64_t expires;
@property (readonly, assign, nonatomic) int64_t issuedAt;
@property (readonly, assign, nonatomic) int64_t issued;
@property (readonly, strong, nonatomic) NSString *capability;
@property (readonly, strong, nonatomic) NSString *clientId;

- (instancetype)init UNAVAILABLE_ATTRIBUTE;

- (instancetype)initWithId:(NSString *)id expires:(int64_t)expires issuedAt:(int64_t)issuedAt capability:(NSString *)capability clientId:(NSString *)clientId;
- (instancetype)initWithId:(NSString *)id expires:(int64_t)expires issued:(int64_t)issued capability:(NSString *)capability clientId:(NSString *)clientId;

+ (instancetype)authTokenWithId:(NSString *)id expires:(int64_t)expires issuedAt:(int64_t)issuedAt capability:(NSString *)capability clientId:(NSString *)clientId;
+ (instancetype)authTokenWithId:(NSString *)id expires:(int64_t)expires issued:(int64_t)issued capability:(NSString *)capability clientId:(NSString *)clientId;

@end

@interface ARTAuthTokenParams : NSObject

@property (readonly, strong, nonatomic) NSString *id;
@property (readonly, strong, nonatomic) NSString *keyName;
@property (readonly, assign, nonatomic) int64_t ttl;
@property (readonly, strong, nonatomic) NSString *capability;
@property (readonly, strong, nonatomic) NSString *clientId;
@property (readonly, assign, nonatomic) int64_t timestamp;
@property (readonly, strong, nonatomic) NSString *nonce;
@property (readonly, strong, nonatomic) NSString *mac;


- (instancetype)init UNAVAILABLE_ATTRIBUTE;

- (instancetype)initWithId:(NSString *)id ttl:(int64_t)ttl capability:(NSString *)capability clientId:(NSString *)clientId timestamp:(int64_t)timestamp nonce:(NSString *)nonce mac:(NSString *)mac;

+ (instancetype)authTokenParamsWithId:(NSString *)id ttl:(int64_t)ttl capability:(NSString *)capability clientId:(NSString *)clientId timestamp:(int64_t)timestamp nonce:(NSString *)nonce mac:(NSString *)mac;

-(NSDictionary *) asDictionary;
@end

typedef id<ARTCancellable>(^ARTAuthCb)(void(^continuation)(ARTAuthToken *));
typedef id<ARTCancellable>(^ARTSignedTokenRequestCb)(ARTAuthTokenParams *tokenParams, void(^continuation)(NSString *));
typedef id<ARTCancellable>(^ARTAuthCb)(void(^continuation)(ARTStatus,ARTTokenDetails *));
typedef id<ARTCancellable>(^ARTSignedTokenRequestCb)(ARTAuthTokenParams *, void(^continuation)(ARTAuthTokenParams *));
typedef NS_ENUM(NSUInteger, ARTAuthMethod) {
ARTAuthMethodBasic,
ARTAuthMethodToken
Expand All @@ -59,12 +61,15 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) {
@property (readwrite, strong, nonatomic) ARTAuthCb authCallback;
@property (readwrite, strong, nonatomic) ARTSignedTokenRequestCb signedTokenRequestCallback;
@property (readwrite, strong, nonatomic) NSURL *authUrl;
@property (readwrite, strong, nonatomic) NSString *keyId;
@property (readwrite, strong, nonatomic) NSString *keyValue;
@property (readwrite, strong, nonatomic) NSString *authToken;
@property (readwrite, strong, nonatomic) NSString *keyName;
@property (readwrite, strong, nonatomic) NSString *keySecret;
@property (readwrite, strong, nonatomic) NSString *token;
@property (readwrite, strong, nonatomic) NSString *capability;
@property (readwrite, strong, nonatomic) NSDictionary *authHeaders;
@property (readwrite, strong, nonatomic) NSString *clientId;
@property (readwrite, assign, nonatomic) BOOL queryTime;
@property (readwrite, assign, nonatomic) BOOL useTokenAuth;


- (instancetype)init;
- (instancetype)initWithKey:(NSString *)key;
Expand All @@ -80,9 +85,12 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) {

- (instancetype)initWithRest:(ARTRest *)rest options:(ARTAuthOptions *)options;

- (id<ARTCancellable>)authHeaders:(id<ARTCancellable>(^)(NSDictionary *))cb;

- (ARTAuthMethod) getAuthMethod;
- (id<ARTCancellable>)authHeadersUseBasic:(BOOL)useBasic cb:(id<ARTCancellable>(^)(NSDictionary *))cb;
- (id<ARTCancellable>)authParams:(id<ARTCancellable>(^)(NSDictionary *))cb;
- (id<ARTCancellable>)authToken:(id<ARTCancellable>(^)(ARTAuthToken *))cb;
- (id<ARTCancellable>)authTokenForceReauth:(BOOL)force cb:(id<ARTCancellable>(^)(ARTAuthToken *))cb;
- (id<ARTCancellable>)authToken:(id<ARTCancellable>(^)(ARTTokenDetails *))cb;
- (id<ARTCancellable>)authTokenForceReauth:(BOOL)force cb:(id<ARTCancellable>(^)(ARTTokenDetails *))cb;


@end
Loading

0 comments on commit 28ada7b

Please sign in to comment.