Skip to content
This repository has been archived by the owner on Dec 18, 2022. It is now read-only.

Commit

Permalink
Bug fixes, removed attestation constants
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Dec 25, 2015
1 parent cbce45e commit 24ddf90
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 59 deletions.
6 changes: 3 additions & 3 deletions Example/SnapchatKit-OSX/SnapchatKit-OSX/main.m
Expand Up @@ -223,11 +223,11 @@ int main(int argc, const char * argv[]) {
[SKClient sharedClient].casperUserAgent = kCasperUserAgent;
#endif

[[SKClient sharedClient] signInWithUsername:kUsername password:kPassword completion:^(NSDictionary *dict, NSError *error) {
[[SKClient sharedClient] restoreSessionWithUsername:kUsername snapchatAuthToken:kAuthToken doGetUpdates:^(NSError *error) {
if (!error) {
SKSession *session = [SKClient sharedClient].currentSession;
[dict writeToFile:[directory stringByAppendingPathComponent:@"current-session.plist"] atomically:YES];
SKLog(@"Session written to file.");
// [dict writeToFile:[directory stringByAppendingPathComponent:@"current-session.plist"] atomically:YES];
// SKLog(@"Session written to file.");

// For debugging purposes, to see the size of the response JSON in memory. Mine was about 300 KB.
// Probably quadratically larger though, since each object also holds onto its JSON dictionary,
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/Model/SKCashTransaction.m
Expand Up @@ -42,7 +42,7 @@ - (NSString *)description {
#pragma mark - Mantle

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{@"patination": @"iter_token",
return @{@"pagination": @"iter_token",
@"status": @"status",
@"amount": @"amount",
@"currencyCode": @"currency_code",
Expand Down
6 changes: 5 additions & 1 deletion Pod/Classes/Model/SKRequest.m
Expand Up @@ -137,13 +137,15 @@ - (id)initWithHeaderFields:(NSDictionary *)httpHeaders {

- (id)initWithPOSTEndpoint:(NSString *)endpoint query:(NSDictionary *)params headers:(NSDictionary *)httpHeaders {
NSParameterAssert(params[@"timestamp"]);
// [[self class] overrideHeaderValuesGlobally:@{SKHeaders.userAgent: SKConsts.userAgent}];

httpHeaders = SKRequestApplyHeaderOverrides(httpHeaders, endpoint);

self = [self initWithHeaderFields:httpHeaders];
if (self) {
SKRequestApplyOverrides(&endpoint, &params);

self.URL = [NSURL URLWithString:[SKConsts.baseURL stringByAppendingPathComponent:endpoint]];
self.URL = [NSURL URLWithString:[SKConsts.baseURL stringByAppendingString:endpoint]];
self.HTTPMethod = @"POST";

NSMutableDictionary *json = [params mutableCopy];
Expand Down Expand Up @@ -174,6 +176,8 @@ - (id)initWithPOSTEndpoint:(NSString *)endpoint query:(NSDictionary *)params hea
[self setValue:timestamp forHTTPHeaderField:SKHeaders.timestamp];
}

// SKLog(@"\nEndpoint: %@\nParams:\n%@\n\nHeaders:\n%@", self.URL, params, httpHeaders);

return self;
}

Expand Down
14 changes: 9 additions & 5 deletions Pod/Classes/Networking/SKClient.m
Expand Up @@ -281,12 +281,12 @@ - (void)getInformationForEndpoint:(NSString *)endpoint callback:(void (^)(NSDict
NSError *jsonError = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
// Content-Type header for specific endpoints
NSDictionary *headers = json[@"headers"];
NSDictionary *headers = json[@"endpoints"][0][@"headers"];
if (headers && ([endpoint isEqualToString:SKEPStories.upload] || [endpoint isEqualToString:SKEPSnaps.upload]))
headers = SKMergeDictionaries(headers, @{SKHeaders.contentType: ([NSString stringWithFormat:@"multipart/form-data; boundary=%@", SKConsts.boundary])});

if ([json[@"code"] integerValue] == 200)
callback(json[@"params"], headers, nil);
callback(json[@"endpoints"][0][@"params"], headers, nil);
else
callback(nil, nil, [SKRequest errorWithMessage:json[@"message"] code:[json[@"status"] integerValue]]);
} else {
Expand Down Expand Up @@ -426,11 +426,15 @@ - (void)updateSession:(ErrorBlock)completion {
SKAssertIsSignedIn(self);

NSDictionary *query = @{@"username": self.username,
@"friends_request": @{@"friends_sync_token": self.currentSession.friendsSyncToken ?: @0},
@"height": @(self.screenSize.height),
@"width": @(self.screenSize.width),
@"max_video_height": @(self.maxVideoSize.height),
@"max_video_width": @(self.maxVideoSize.width),
@"include_client_settings": @"true"};
@"screen_height_px": @(self.screenSize.height),
@"screen_width_px": @(self.screenSize.width),
@"screen_width_in": @0,
@"screen_height_in": @0,
@"checksums_dict": @"{}",
@"features_map": @"{}"};
[self postTo:SKEPUpdate.all query:query callback:^(NSDictionary *json, NSError *error) {
if (!error) {
_currentSession = [[SKSession alloc] initWithDictionary:json];
Expand Down
25 changes: 0 additions & 25 deletions Pod/Classes/SnapchatKit-Constants.h
Expand Up @@ -93,31 +93,6 @@ extern BOOL SKMediaKindIsVideo(SKMediaKind mediaKind);
extern NSString * const SKNoConversationExistsYet;
extern NSString * const SKTemporaryLoginFailure;

/** Various attestation related strings. */
SK_NAMESPACE(SKAttestation, {
/** The user agent specific to making the attestation request. */
NSNSString *userAgent;
/** The sha256 digest of the certificate used to sign the Snapchat APK, base 64 encoded. It should never change. */
NSNSString *certificateDigest;
/** Google Play Services version used to make the attestation request. */
NSInteger GMSVersion;
/** The URL used to get the bytecode needed to generate droidguard and attestation. */
NSNSString *protobufBytecodeURL;
NSNSString *protobufPOSTURL;
NSNSString *attestationURL;
NSNSString *digest9_8;
NSNSString *digest9_9;
NSNSString *digest9_10;
NSNSString *digest9_11;
NSNSString *digest9_12_0_1;
NSNSString *digest9_12_1;
NSNSString *digest9_12_2;
NSNSString *digest9_13;
NSNSString *digest9_14;
NSNSString *digest9_14_2;

});

SK_NAMESPACE(SKConsts, {
/** The API URL. iOS uses the /bq endpoint, Android clients use the /ph endpoint. */
NSNSString *baseURL;
Expand Down
26 changes: 3 additions & 23 deletions Pod/Classes/SnapchatKit-Constants.m
Expand Up @@ -95,30 +95,10 @@ BOOL SKMediaKindIsVideo(SKMediaKind mediaKind) {

#pragma mark - General API constants -

#pragma mark Attestation
SK_NAMESPACE_IMP(SKAttestation) {
.userAgent = @"SafetyNet/7899000 (WIKO JZO54K); gzip",
.certificateDigest = @"Lxyq/KHtMNC044hj7vq+oOgVcR+kz3m4IlGaglnZWlg=",
.GMSVersion = 7329038,
.protobufBytecodeURL = @"https://www.googleapis.com/androidantiabuse/v1/x/create?alt=PROTO&key=AIzaSyBofcZsgLSS7BOnBjZPEkk4rYwzOIz-lTI",
.protobufPOSTURL = @"https://api.casper.io/snapchat/attestation/attest",
.attestationURL = @"https://www.googleapis.com/androidcheck/v1/attestations/attest?alt=JSON&key=AIzaSyDqVnJBjE5ymo--oBJt3On7HQx9xNm1RHA",
.digest9_8 = @"vXCcGhQ7RfL1LUiE3F6vcNORNo7IFSOvuDBunK87mEI=",
.digest9_9 = @"Yk9Wqmx7TrTatldWI+5PWbQjGA8Gi8ZoO8X9OUAw1hg=",
.digest9_10 = @"JJShKOLH4YYjWZlJQ71A2dPTcmxbaMboyfo0nsKYayE=",
.digest9_11 = @"nNsTUhHYJ943NG6vAPNl+tRr1vktNb9HpvRxZuu/rrE=",
.digest9_12_0_1 = @"W4snbl56it9XbT2lsL4gyHwMsElnmOPBDp+iIYqbGcI=",
.digest9_12_1 = @"fGZExseKdFH1bltkKloaAGfGx0vnKDDymKiJAiLo3dU=",
.digest9_12_2 = @"LMQNajaQ4SO7vNaQS1FRokxCtQXeIHwKZiJYhMczDGk=",
.digest9_13 = @"BWDe2a5b3I26Yw6z4Prvh2aEMRcf2B1FMs8136QIeCM=",
.digest9_14 = @"k6IftsTIpJeVhZDoHZv9zxDhE7HuN50PpO3O/zIXxsU=",
.digest9_14_2 = @"5O40Rllov9V8PpwD5zPmmp+GQi7UMIWz2A0LWZA7UX0="
};

#pragma mark Misc
SK_NAMESPACE_IMP(SKConsts) {
.baseURL = @"https://feelinsonice-hrd.appspot.com",
.userAgent = @"Snapchat/9.16.1.0 (SM-N9005; Android 5.0.2; gzip)", //Snapchat/9.16.1.0 (HTC One; Android 4.4.2#302626.7#19; gzip)";
.baseURL = @"https://app.snapchat.com",
.userAgent = @"Snapchat/9.21.0.1 (iPhone8,1; iOS 9.0.2; gzip)",//@"Snapchat/9.16.1.0 (SM-N9005; Android 5.0.2; gzip)", //Snapchat/9.16.1.0 (HTC One; Android 4.4.2#302626.7#19; gzip)",
.eventsURL = @"https://sc-analytics.appspot.com/post_events",
.analyticsURL = @"https://sc-analytics.appspot.com/analytics/bz",
.secret = @"iEk21fuwZApXlz93750dmW22pw389dPwOk",
Expand All @@ -128,7 +108,7 @@ BOOL SKMediaKindIsVideo(SKMediaKind mediaKind) {
.boundary = @"Boundary+0xAbCdEfGbOuNdArY",
.deviceToken1i = @"dtoken1i",
.deviceToken1v = @"dtoken1v",
.snapchatVersion = @"9.16.1.0"
.snapchatVersion = @"9.21.0.1"
};

#pragma mark Header fields / values
Expand Down
2 changes: 1 addition & 1 deletion SnapchatKit.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SnapchatKit"
s.version = "0.3.6"
s.version = "0.4.0"
s.summary = "An Objective-C implementation of the unofficial Snapchat API."
s.homepage = "https://github.com/ThePantsThief/SnapchatKit"
s.license = 'MIT'
Expand Down

0 comments on commit 24ddf90

Please sign in to comment.