@appzung/react-native-code-push 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AlertAdapter.js +24 -0
- package/CONTRIBUTING.md +136 -0
- package/CodePush.js +666 -0
- package/CodePush.podspec +27 -0
- package/LICENSE.md +13 -0
- package/README.md +386 -0
- package/RestartManager.js +59 -0
- package/android/app/build.gradle +31 -0
- package/android/app/proguard-rules.pro +25 -0
- package/android/app/src/main/AndroidManifest.xml +10 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +395 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +34 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +641 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +369 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +267 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +236 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +190 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
- package/android/build.gradle +20 -0
- package/android/codepush.gradle +113 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +20 -0
- package/android/gradlew +164 -0
- package/android/gradlew.bat +90 -0
- package/android/settings.gradle +1 -0
- package/docs/api-android.md +65 -0
- package/docs/api-ios.md +31 -0
- package/docs/api-js.md +592 -0
- package/docs/multi-deployment-testing-android.md +107 -0
- package/docs/multi-deployment-testing-ios.md +53 -0
- package/docs/setup-android.md +406 -0
- package/docs/setup-ios.md +229 -0
- package/docs/setup-windows.md +65 -0
- package/gulpfile.js +302 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
- package/ios/CodePush/Base64/README.md +47 -0
- package/ios/CodePush/CodePush.h +235 -0
- package/ios/CodePush/CodePush.m +1041 -0
- package/ios/CodePush/CodePushConfig.m +116 -0
- package/ios/CodePush/CodePushDownloadHandler.m +130 -0
- package/ios/CodePush/CodePushErrorUtils.m +20 -0
- package/ios/CodePush/CodePushPackage.m +598 -0
- package/ios/CodePush/CodePushTelemetryManager.m +175 -0
- package/ios/CodePush/CodePushUpdateUtils.m +376 -0
- package/ios/CodePush/CodePushUtils.m +9 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
- package/ios/CodePush/JWT/LICENSE +19 -0
- package/ios/CodePush/JWT/README.md +489 -0
- package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
- package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
- package/ios/CodePush/SSZipArchive/Common.h +81 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
- package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
- package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
- package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/logging.js +6 -0
- package/package-mixins.js +69 -0
- package/package.json +47 -0
- package/request-fetch-adapter.js +52 -0
- package/scripts/generateBundledResourcesHash.js +125 -0
- package/scripts/getFilesInFolder.js +19 -0
- package/scripts/postlink/android/postlink.js +87 -0
- package/scripts/postlink/ios/postlink.js +116 -0
- package/scripts/postlink/run.js +11 -0
- package/scripts/postunlink/android/postunlink.js +74 -0
- package/scripts/postunlink/ios/postunlink.js +87 -0
- package/scripts/postunlink/run.js +11 -0
- package/scripts/recordFilesBeforeBundleCommand.js +41 -0
- package/scripts/tools/linkToolsAndroid.js +57 -0
- package/scripts/tools/linkToolsIos.js +130 -0
- package/typings/react-native-code-push.d.ts +446 -0
- package/windows/CodePush/CodePush.csproj +128 -0
- package/windows/CodePush/CodePushUtils.cs +47 -0
- package/windows/CodePush/FileUtils.cs +40 -0
- package/windows/CodePush/Properties/AssemblyInfo.cs +29 -0
- package/windows/CodePush/Properties/CodePush.rd.xml +33 -0
- package/windows/CodePush/UpdateManager.cs +305 -0
- package/windows/CodePush/UpdateUtils.cs +46 -0
- package/windows/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
- package/windows/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
- package/windows/CodePush.Net46/CodePush.Net46.csproj +103 -0
- package/windows/CodePush.Net46/CodePushUtils.cs +158 -0
- package/windows/CodePush.Net46/FileUtils.cs +55 -0
- package/windows/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
- package/windows/CodePush.Net46/UpdateManager.cs +330 -0
- package/windows/CodePush.Net46/UpdateUtils.cs +70 -0
- package/windows/CodePush.Net46/packages.config +5 -0
- package/windows/CodePush.Shared/CodePush.Shared.projitems +22 -0
- package/windows/CodePush.Shared/CodePush.Shared.shproj +13 -0
- package/windows/CodePush.Shared/CodePushConstants.cs +35 -0
- package/windows/CodePush.Shared/CodePushNativeModule.cs +329 -0
- package/windows/CodePush.Shared/CodePushReactPackage.cs +235 -0
- package/windows/CodePush.Shared/CodePushUtils.cs +70 -0
- package/windows/CodePush.Shared/InstallMode.cs +9 -0
- package/windows/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
- package/windows/CodePush.Shared/SettingsManager.cs +148 -0
- package/windows/CodePush.Shared/TelemetryManager.cs +250 -0
- package/windows/CodePush.Shared/UpdateState.cs +9 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JWTAlgorithmDataHolder.m
|
|
3
|
+
// JWT
|
|
4
|
+
//
|
|
5
|
+
// Created by Lobanov Dmitry on 31.08.16.
|
|
6
|
+
// Copyright © 2016 Karma. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "JWTAlgorithmDataHolder.h"
|
|
10
|
+
#import "JWTAlgorithmFactory.h"
|
|
11
|
+
#import "JWTAlgorithmNone.h"
|
|
12
|
+
#import "JWTRSAlgorithm.h"
|
|
13
|
+
#import "JWTAlgorithmHSBase.h"
|
|
14
|
+
#import "JWTAlgorithmRSBase.h"
|
|
15
|
+
#import "JWTBase64Coder.h"
|
|
16
|
+
|
|
17
|
+
@interface JWTAlgorithmBaseDataHolder()
|
|
18
|
+
// not needed by algorithm adoption.
|
|
19
|
+
// @property (copy, nonatomic, readwrite) NSData *internalSecretData;
|
|
20
|
+
// @property (strong, nonatomic, readwrite) id <JWTAlgorithm> internalAlgorithm;
|
|
21
|
+
|
|
22
|
+
#pragma mark - Setters
|
|
23
|
+
/**
|
|
24
|
+
Sets jwtSecret and returns the JWTAlgorithmBaseDataHolder to allow for method chaining
|
|
25
|
+
*/
|
|
26
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmBaseDataHolder *(^secret)(NSString *secret);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
Sets jwtSecretData and returns the JWTAlgorithmBaseDataHolder to allow for method chaining
|
|
30
|
+
*/
|
|
31
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmBaseDataHolder *(^secretData)(NSData *secretData);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
Sets jwtAlgorithm and returns the JWTAlgorithmBaseDataHolder to allow for method chaining
|
|
35
|
+
*/
|
|
36
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmBaseDataHolder *(^algorithm)(id<JWTAlgorithm>algorithm);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
Sets jwtAlgorithmName and returns the JWTAlgorithmBaseDataHolder to allow for method chaining. See list of names in appropriate headers.
|
|
40
|
+
*/
|
|
41
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmBaseDataHolder *(^algorithmName)(NSString *algorithmName);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
Sets stringCoder and returns the JWTAlgorithmBaseDataHolder to allow for method chaining. See list of names in appropriate headers.
|
|
45
|
+
*/
|
|
46
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmBaseDataHolder *(^stringCoder)(id<JWTStringCoder__Protocol> stringCoder);
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
@interface JWTAlgorithmBaseDataHolder (Convertions)
|
|
50
|
+
|
|
51
|
+
- (NSData *)dataFromString:(NSString *)string;
|
|
52
|
+
- (NSString *)stringFromData:(NSData *)data;
|
|
53
|
+
|
|
54
|
+
@end
|
|
55
|
+
|
|
56
|
+
@implementation JWTAlgorithmBaseDataHolder (Convertions)
|
|
57
|
+
#pragma mark - Convertions
|
|
58
|
+
- (NSData *)dataFromString:(NSString *)string {
|
|
59
|
+
NSData *result = [self.internalStringCoder dataWithString:string];
|
|
60
|
+
|
|
61
|
+
if (result == nil) {
|
|
62
|
+
// tell about it?!
|
|
63
|
+
NSLog(@"%@ %@ something went wrong. Data is not base64encoded", self.debugDescription, NSStringFromSelector(_cmd));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;// ?: [string dataUsingEncoding:NSUTF8StringEncoding];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (NSString *)stringFromData:(NSData *)data {
|
|
70
|
+
NSString *result = [self.internalStringCoder stringWithData:data];
|
|
71
|
+
|
|
72
|
+
if (result == nil) {
|
|
73
|
+
NSLog(@"%@ %@ something went wrong. String is not base64encoded", self.debugDescription, NSStringFromSelector(_cmd));
|
|
74
|
+
}
|
|
75
|
+
return result ?: [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
76
|
+
}
|
|
77
|
+
@end
|
|
78
|
+
|
|
79
|
+
@interface JWTAlgorithmBaseDataHolder (Fluent)
|
|
80
|
+
- (void)setupFluent;
|
|
81
|
+
@end
|
|
82
|
+
|
|
83
|
+
@implementation JWTAlgorithmBaseDataHolder (Fluent)
|
|
84
|
+
#pragma mark - Fluent
|
|
85
|
+
- (instancetype)secretData:(NSData *)secretData {
|
|
86
|
+
self.internalSecretData = secretData;
|
|
87
|
+
return self;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (instancetype)secret:(NSString *)secret {
|
|
91
|
+
self.internalSecretData = [self dataFromString:secret];
|
|
92
|
+
return self;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (instancetype)algorithm:(id<JWTAlgorithm>)algorithm {
|
|
96
|
+
self.internalAlgorithm = algorithm;
|
|
97
|
+
return self;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (instancetype)algorithmName:(NSString *)algorithmName {
|
|
101
|
+
self.internalAlgorithm = [JWTAlgorithmFactory algorithmByName:algorithmName];
|
|
102
|
+
return self;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (instancetype)stringCoder:(id<JWTStringCoder__Protocol>)stringCoder {
|
|
106
|
+
self.internalStringCoder = stringCoder;
|
|
107
|
+
return self;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (void)setupFluent {
|
|
111
|
+
__weak typeof(self) weakSelf = self;
|
|
112
|
+
self.secret = ^(NSString *secret) {
|
|
113
|
+
return [weakSelf secret:secret];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
self.secretData = ^(NSData *secretData) {
|
|
117
|
+
return [weakSelf secretData:secretData];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
self.algorithm = ^(id<JWTAlgorithm> algorithm) {
|
|
121
|
+
return [weakSelf algorithm:algorithm];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
self.algorithmName = ^(NSString *algorithmName) {
|
|
125
|
+
return [weakSelf algorithmName:algorithmName];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
self.stringCoder = ^(id <JWTStringCoder__Protocol> stringCoder) {
|
|
129
|
+
return [weakSelf stringCoder:stringCoder];
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
@end
|
|
133
|
+
|
|
134
|
+
@interface JWTAlgorithmBaseDataHolder (Debug)
|
|
135
|
+
- (NSDictionary *)debugInformation;
|
|
136
|
+
@end
|
|
137
|
+
@implementation JWTAlgorithmBaseDataHolder (Debug)
|
|
138
|
+
- (NSString *)debugDescription {
|
|
139
|
+
return [[self debugInformation] debugDescription];
|
|
140
|
+
}
|
|
141
|
+
- (NSDictionary *)debugInformation {
|
|
142
|
+
return @{
|
|
143
|
+
@"algorithmName" : self.internalAlgorithmName ?: @"unknown",
|
|
144
|
+
@"algorithm" : [self.internalAlgorithm debugDescription] ?: @"unknown",
|
|
145
|
+
@"secretData" : [self.internalSecretData debugDescription] ?: @"unknown",
|
|
146
|
+
@"stringCoder" : [self.internalStringCoder debugDescription] ?: @"unknown"
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@end
|
|
151
|
+
|
|
152
|
+
@implementation JWTAlgorithmBaseDataHolder
|
|
153
|
+
@synthesize internalAlgorithm;
|
|
154
|
+
@synthesize internalSecretData;
|
|
155
|
+
@synthesize internalStringCoder = _internalStringCoder;
|
|
156
|
+
|
|
157
|
+
- (id<JWTStringCoder__Protocol>)internalStringCoder {
|
|
158
|
+
return _internalStringCoder ?: [JWTBase64Coder new];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#pragma mark - Custom Getters
|
|
162
|
+
- (NSString *)internalAlgorithmName {
|
|
163
|
+
return [self.internalAlgorithm name];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
- (NSString *)internalSecret {
|
|
167
|
+
return [self stringFromData:self.internalSecretData];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
- (instancetype)init {
|
|
171
|
+
self = [super init];
|
|
172
|
+
if (self) {
|
|
173
|
+
[self setupFluent];
|
|
174
|
+
}
|
|
175
|
+
return self;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#pragma mark - Copy
|
|
179
|
+
- (id)copyWithZone:(NSZone *)zone {
|
|
180
|
+
JWTAlgorithmBaseDataHolder *holder = [self.class new];
|
|
181
|
+
holder.internalAlgorithm = self.internalAlgorithm;
|
|
182
|
+
holder.internalSecretData = self.internalSecretData;
|
|
183
|
+
holder.internalStringCoder = self.internalStringCoder;
|
|
184
|
+
return holder;
|
|
185
|
+
}
|
|
186
|
+
@end
|
|
187
|
+
|
|
188
|
+
@interface JWTAlgorithmBaseDataHolder(Create)
|
|
189
|
+
- (instancetype)initWithAlgorithmName:(NSString *)name;
|
|
190
|
+
@end
|
|
191
|
+
|
|
192
|
+
@implementation JWTAlgorithmBaseDataHolder(Create)
|
|
193
|
+
- (instancetype)initWithAlgorithmName:(NSString *)name {
|
|
194
|
+
return [self init].algorithmName(name);
|
|
195
|
+
}
|
|
196
|
+
@end
|
|
197
|
+
|
|
198
|
+
@implementation JWTAlgorithmNoneDataHolder
|
|
199
|
+
- (instancetype)init {
|
|
200
|
+
if (self = [super init]) {
|
|
201
|
+
self.internalAlgorithm = [JWTAlgorithmFactory algorithmByName:JWTAlgorithmNameNone];
|
|
202
|
+
self.internalSecretData = nil;
|
|
203
|
+
}
|
|
204
|
+
return self;
|
|
205
|
+
}
|
|
206
|
+
@end
|
|
207
|
+
|
|
208
|
+
@implementation JWTAlgorithmHSFamilyDataHolder
|
|
209
|
+
+ (instancetype)createWithAlgorithm256 {
|
|
210
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameHS256];
|
|
211
|
+
}
|
|
212
|
+
+ (instancetype)createWithAlgorithm384 {
|
|
213
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameHS384];
|
|
214
|
+
}
|
|
215
|
+
+ (instancetype)createWithAlgorithm512 {
|
|
216
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameHS512];
|
|
217
|
+
}
|
|
218
|
+
@end
|
|
219
|
+
|
|
220
|
+
@interface JWTAlgorithmRSFamilyDataHolder()
|
|
221
|
+
#pragma mark - Getters
|
|
222
|
+
@property (copy, nonatomic, readwrite) NSString *internalPrivateKeyCertificatePassphrase;
|
|
223
|
+
@property (copy, nonatomic, readwrite) NSString *internalKeyExtractorType;
|
|
224
|
+
@property (strong, nonatomic, readwrite) id<JWTCryptoKeyProtocol> internalSignKey;
|
|
225
|
+
@property (strong, nonatomic, readwrite) id<JWTCryptoKeyProtocol> internalVerifyKey;
|
|
226
|
+
#pragma mark - Setters
|
|
227
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmRSFamilyDataHolder *(^privateKeyCertificatePassphrase)(NSString *privateKeyCertificatePassphrase);
|
|
228
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmRSFamilyDataHolder *(^keyExtractorType)(NSString *keyExtractorType);
|
|
229
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmRSFamilyDataHolder *(^signKey)(id<JWTCryptoKeyProtocol> signKey);
|
|
230
|
+
@property (copy, nonatomic, readwrite) JWTAlgorithmRSFamilyDataHolder *(^verifyKey)(id<JWTCryptoKeyProtocol> verifyKey);
|
|
231
|
+
@end
|
|
232
|
+
|
|
233
|
+
@implementation JWTAlgorithmRSFamilyDataHolder (Debug)
|
|
234
|
+
- (NSDictionary *)debugInformation {
|
|
235
|
+
NSDictionary *add = @{@"privateKeyCertificatePassphrase" : self.internalPrivateKeyCertificatePassphrase ?: @"unknown",
|
|
236
|
+
@"keyExtractorType" : self.internalKeyExtractorType ?: @"unknown",
|
|
237
|
+
@"signKey" : [self.signKey debugDescription] ?: @"unknown",
|
|
238
|
+
@"verifyKey" : [self.verifyKey debugDescription] ?: @"unknown"
|
|
239
|
+
};
|
|
240
|
+
NSMutableDictionary *result = [[super debugInformation] mutableCopy];
|
|
241
|
+
[result addEntriesFromDictionary:add];
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
@end
|
|
245
|
+
|
|
246
|
+
@implementation JWTAlgorithmRSFamilyDataHolder
|
|
247
|
+
|
|
248
|
+
#pragma mark - Initialization
|
|
249
|
+
+ (instancetype)createWithAlgorithm256 {
|
|
250
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameRS256];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
+ (instancetype)createWithAlgorithm384 {
|
|
254
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameRS384];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
+ (instancetype)createWithAlgorithm512 {
|
|
258
|
+
return [[self alloc] initWithAlgorithmName:JWTAlgorithmNameRS512];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#pragma mark - Getters
|
|
262
|
+
- (id<JWTAlgorithm>)internalAlgorithm {
|
|
263
|
+
id <JWTAlgorithm> algorithm = [super internalAlgorithm];
|
|
264
|
+
if ([algorithm conformsToProtocol:@protocol(JWTRSAlgorithm)]) {
|
|
265
|
+
// copy?
|
|
266
|
+
id<JWTRSAlgorithm>currentAlgorithm = [(id <JWTRSAlgorithm>)algorithm copyWithZone:nil];
|
|
267
|
+
currentAlgorithm.privateKeyCertificatePassphrase = self.internalPrivateKeyCertificatePassphrase;
|
|
268
|
+
currentAlgorithm.keyExtractorType = self.internalKeyExtractorType;
|
|
269
|
+
currentAlgorithm.signKey = self.internalSignKey;
|
|
270
|
+
currentAlgorithm.verifyKey = self.internalVerifyKey;
|
|
271
|
+
algorithm = currentAlgorithm;
|
|
272
|
+
}
|
|
273
|
+
return algorithm;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
#pragma mark - Setters
|
|
277
|
+
- (instancetype)privateKeyCertificatePassphrase:(NSString *)passphrase {
|
|
278
|
+
self.internalPrivateKeyCertificatePassphrase = passphrase;
|
|
279
|
+
return self;
|
|
280
|
+
}
|
|
281
|
+
- (instancetype)keyExtractorType:(NSString *)type {
|
|
282
|
+
self.internalKeyExtractorType = type;
|
|
283
|
+
return self;
|
|
284
|
+
}
|
|
285
|
+
- (instancetype)signKey:(id<JWTCryptoKeyProtocol>)key {
|
|
286
|
+
self.internalSignKey = key;
|
|
287
|
+
return self;
|
|
288
|
+
}
|
|
289
|
+
- (instancetype)verifyKey:(id<JWTCryptoKeyProtocol>)key {
|
|
290
|
+
self.internalVerifyKey = key;
|
|
291
|
+
return self;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
#pragma mark - Copy
|
|
295
|
+
- (id)copyWithZone:(NSZone *)zone {
|
|
296
|
+
JWTAlgorithmRSFamilyDataHolder *holder = [super copyWithZone:zone];
|
|
297
|
+
holder.internalPrivateKeyCertificatePassphrase = self.internalPrivateKeyCertificatePassphrase;
|
|
298
|
+
holder.internalKeyExtractorType = self.internalKeyExtractorType;
|
|
299
|
+
holder.internalSignKey = self.internalSignKey;
|
|
300
|
+
holder.internalVerifyKey = self.internalVerifyKey;
|
|
301
|
+
return holder;
|
|
302
|
+
}
|
|
303
|
+
@end
|
|
304
|
+
|
|
305
|
+
@implementation JWTAlgorithmRSFamilyDataHolder (Fluent)
|
|
306
|
+
- (void)setupFluent {
|
|
307
|
+
[super setupFluent];
|
|
308
|
+
__weak typeof(self) weakSelf = self;
|
|
309
|
+
self.privateKeyCertificatePassphrase = ^(NSString *privateKeyCertificatePassphrase) {
|
|
310
|
+
return [weakSelf privateKeyCertificatePassphrase:privateKeyCertificatePassphrase];
|
|
311
|
+
};
|
|
312
|
+
self.keyExtractorType = ^(NSString *keyExtractorType) {
|
|
313
|
+
return [weakSelf keyExtractorType:keyExtractorType];
|
|
314
|
+
};
|
|
315
|
+
self.signKey = ^(id<JWTCryptoKeyProtocol> key){
|
|
316
|
+
return [weakSelf signKey:key];
|
|
317
|
+
};
|
|
318
|
+
self.verifyKey = ^(id<JWTCryptoKeyProtocol> key){
|
|
319
|
+
return [weakSelf verifyKey:key];
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
@end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JWTAlgorithmDataHolderChain.h
|
|
3
|
+
// JWT
|
|
4
|
+
//
|
|
5
|
+
// Created by Lobanov Dmitry on 02.10.16.
|
|
6
|
+
// Copyright © 2016 Karma. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "JWTAlgorithmDataHolder.h"
|
|
11
|
+
|
|
12
|
+
@interface JWTAlgorithmDataHolderChain : NSObject
|
|
13
|
+
|
|
14
|
+
@property (strong, nonatomic, readonly) NSArray *holders;
|
|
15
|
+
|
|
16
|
+
#pragma mark - Initialization
|
|
17
|
+
- (instancetype)initWithHolders:(NSArray *)holders;
|
|
18
|
+
- (instancetype)initWithHolder:(id<JWTAlgorithmDataHolderProtocol>)holder;
|
|
19
|
+
|
|
20
|
+
#pragma mark - Appending
|
|
21
|
+
- (instancetype)chainByAppendingChain:(JWTAlgorithmDataHolderChain *)chain;
|
|
22
|
+
- (instancetype)chainByAppendingHolders:(NSArray *)holders;
|
|
23
|
+
- (instancetype)chainByAppendingHolder:(id<JWTAlgorithmDataHolderProtocol>)holder;
|
|
24
|
+
|
|
25
|
+
#pragma mark - Create
|
|
26
|
+
+ (instancetype)chainWithHolders:(NSArray *)holders;
|
|
27
|
+
+ (instancetype)chainWithHolder:(id<JWTAlgorithmDataHolderProtocol>)holder;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@interface JWTAlgorithmDataHolderChain (HoldersPopulation)
|
|
31
|
+
- (NSArray *)singleAlgorithm:(id<JWTAlgorithm>)algorithm withManySecretData:(NSArray *)secretsData;
|
|
32
|
+
- (NSArray *)singleSecretData:(NSData *)secretData withManyAlgorithms:(NSArray *)algorithms;
|
|
33
|
+
|
|
34
|
+
- (instancetype)chainByPopulatingAlgorithm:(id<JWTAlgorithm>)algorithm withManySecretData:(NSArray *)secretsData;
|
|
35
|
+
- (instancetype)chainByPopulatingSecretData:(NSData *)secretData withManyAlgorithms:(NSArray *)algorithms;
|
|
36
|
+
|
|
37
|
+
@end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JWTAlgorithmDataHolderChain.m
|
|
3
|
+
// JWT
|
|
4
|
+
//
|
|
5
|
+
// Created by Lobanov Dmitry on 02.10.16.
|
|
6
|
+
// Copyright © 2016 Karma. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "JWTAlgorithmDataHolderChain.h"
|
|
10
|
+
|
|
11
|
+
@interface JWTAlgorithmDataHolderChain()
|
|
12
|
+
|
|
13
|
+
@property (strong, nonatomic, readwrite) NSArray *holders;
|
|
14
|
+
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation JWTAlgorithmDataHolderChain
|
|
18
|
+
|
|
19
|
+
- (NSArray *)holders {
|
|
20
|
+
if (!_holders) {
|
|
21
|
+
_holders = @[];
|
|
22
|
+
}
|
|
23
|
+
return _holders;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#pragma mark - Initialization
|
|
27
|
+
- (instancetype)initWithHolders:(NSArray *)holders {
|
|
28
|
+
self = [super init];
|
|
29
|
+
if (holders) {
|
|
30
|
+
// check that holders conform to protocol
|
|
31
|
+
NSArray *checkedHolders = [holders filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
|
|
32
|
+
return [evaluatedObject conformsToProtocol:@protocol(JWTAlgorithmDataHolderProtocol)];
|
|
33
|
+
}]];
|
|
34
|
+
self.holders = checkedHolders;
|
|
35
|
+
}
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (instancetype)initWithHolder:(id<JWTAlgorithmDataHolderProtocol>)holder {
|
|
40
|
+
if (holder) {
|
|
41
|
+
return [self initWithHolders:@[holder]];
|
|
42
|
+
}
|
|
43
|
+
return nil;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#pragma mark - Appending
|
|
47
|
+
- (instancetype)chainByAppendingChain:(JWTAlgorithmDataHolderChain *)chain {
|
|
48
|
+
NSArray *holders = self.holders;
|
|
49
|
+
if (chain) {
|
|
50
|
+
holders = [holders arrayByAddingObjectsFromArray:chain.holders];
|
|
51
|
+
}
|
|
52
|
+
return [[self.class alloc] initWithHolders:holders];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (instancetype)chainByAppendingHolders:(NSArray *)holders {
|
|
56
|
+
// create new chain with holders
|
|
57
|
+
JWTAlgorithmDataHolderChain *chain = nil;
|
|
58
|
+
if (holders) {
|
|
59
|
+
chain = [[self.class alloc] initWithHolders:holders];
|
|
60
|
+
}
|
|
61
|
+
return [self chainByAppendingChain:chain];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (instancetype)chainByAppendingHolder:(id<JWTAlgorithmDataHolderProtocol>)holder {
|
|
65
|
+
return [self chainByAppendingHolders:holder ? @[holder] : nil];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#pragma mark - Create
|
|
69
|
+
+ (instancetype)chainWithHolders:(NSArray *)holders {
|
|
70
|
+
return [[self new] chainByAppendingHolders:holders];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
+ (instancetype)chainWithHolder:(id<JWTAlgorithmDataHolderProtocol>)holder {
|
|
74
|
+
return [[self new] chainByAppendingHolder:holder];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#pragma mark - Debug
|
|
78
|
+
- (NSString *)debugDescription {
|
|
79
|
+
return [NSString stringWithFormat:@"%@ holders: %@", self.class, [self.holders valueForKey:@"debugDescription"]];
|
|
80
|
+
}
|
|
81
|
+
@end
|
|
82
|
+
|
|
83
|
+
@implementation JWTAlgorithmDataHolderChain (Convenient)
|
|
84
|
+
- (id<JWTAlgorithmDataHolderProtocol>)firstHolderByAlgorithm:(id<JWTAlgorithm>)algorithm {
|
|
85
|
+
NSInteger index = [self.holders indexOfObjectPassingTest:^BOOL(id <JWTAlgorithmDataHolderProtocol> _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
86
|
+
return [[[obj internalAlgorithm] name] isEqualToString:[algorithm name]];
|
|
87
|
+
}];
|
|
88
|
+
if (index != NSNotFound) {
|
|
89
|
+
return self.holders[index];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return nil;
|
|
93
|
+
}
|
|
94
|
+
- (id<JWTAlgorithmDataHolderProtocol>)firstHolderBySecretData:(NSData *)secretData {
|
|
95
|
+
NSInteger index = [self.holders indexOfObjectPassingTest:^BOOL(id <JWTAlgorithmDataHolderProtocol> _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
96
|
+
return [[obj internalSecretData] isEqualToData:secretData];
|
|
97
|
+
}];
|
|
98
|
+
if (index != NSNotFound) {
|
|
99
|
+
return self.holders[index];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return nil;
|
|
103
|
+
}
|
|
104
|
+
- (NSArray *)singleAlgorithm:(id<JWTAlgorithm>)algorithm withManySecretData:(NSArray *)secretsData {
|
|
105
|
+
NSArray *holders = @[];
|
|
106
|
+
|
|
107
|
+
id holder = [self firstHolderByAlgorithm:algorithm];
|
|
108
|
+
|
|
109
|
+
if (!holder) {
|
|
110
|
+
return holders;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (NSData *secretData in secretsData) {
|
|
114
|
+
id<JWTAlgorithmDataHolderProtocol> newHolder = [holder copy];
|
|
115
|
+
[newHolder setInternalSecretData:secretData];
|
|
116
|
+
holders = [holders arrayByAddingObject:newHolder];
|
|
117
|
+
}
|
|
118
|
+
return holders;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- (NSArray *)singleSecretData:(NSData *)secretData withManyAlgorithms:(NSArray *)algorithms {
|
|
122
|
+
NSArray *holders = @[];
|
|
123
|
+
|
|
124
|
+
id holder = [self firstHolderBySecretData:secretData];
|
|
125
|
+
|
|
126
|
+
if (!holder) {
|
|
127
|
+
return holders;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (id<JWTAlgorithm>algorithm in algorithms) {
|
|
131
|
+
id<JWTAlgorithmDataHolderProtocol> newHolder = [holder copy];
|
|
132
|
+
[newHolder setInternalAlgorithm:algorithm];
|
|
133
|
+
[holders arrayByAddingObject:newHolder];
|
|
134
|
+
}
|
|
135
|
+
return holders;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
- (instancetype)chainByPopulatingAlgorithm:(id<JWTAlgorithm>)algorithm withManySecretData:(NSArray *)secretsData {
|
|
139
|
+
return [[self.class alloc] initWithHolders:[self singleAlgorithm:algorithm withManySecretData:secretsData]];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
- (instancetype)chainByPopulatingSecretData:(NSData *)secretData withManyAlgorithms:(NSArray *)algorithms {
|
|
143
|
+
return [[self.class alloc] initWithHolders:[self singleSecretData:secretData withManyAlgorithms:algorithms]];
|
|
144
|
+
}
|
|
145
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JWTAlgorithmRSBase.h
|
|
3
|
+
// JWT
|
|
4
|
+
//
|
|
5
|
+
// Created by Lobanov Dmitry on 13.03.16.
|
|
6
|
+
// Copyright © 2016 Karma. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "JWTRSAlgorithm.h"
|
|
11
|
+
extern NSString *const JWTAlgorithmNameRS256;
|
|
12
|
+
extern NSString *const JWTAlgorithmNameRS384;
|
|
13
|
+
extern NSString *const JWTAlgorithmNameRS512;
|
|
14
|
+
|
|
15
|
+
@interface JWTAlgorithmRSBase : NSObject <JWTRSAlgorithm>
|
|
16
|
+
|
|
17
|
+
@property (assign, nonatomic, readonly) size_t ccSHANumberDigestLength;
|
|
18
|
+
@property (assign, nonatomic, readonly) uint32_t secPaddingPKCS1SHANumber;
|
|
19
|
+
- (unsigned char *)CC_SHANumberWithData:(const void *)data withLength:(uint32_t)len withHashBytes:(unsigned char *)hashBytes;
|
|
20
|
+
|
|
21
|
+
@end
|
|
22
|
+
|
|
23
|
+
@interface JWTAlgorithmRSBase (Create)
|
|
24
|
+
|
|
25
|
+
+ (instancetype)algorithm256;
|
|
26
|
+
+ (instancetype)algorithm384;
|
|
27
|
+
+ (instancetype)algorithm512;
|
|
28
|
+
+ (instancetype)mutableAlgorithm __deprecated;
|
|
29
|
+
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
// when you can't live without mutability, uncomment.
|
|
34
|
+
@class JWTAlgorithmRSFamilyMemberMutable;
|
|
35
|
+
*/
|