@appzung/react-native-code-push 8.3.2 → 10.0.0-rc1
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/CodePush.js +22 -19
- package/CodePush.podspec +3 -3
- package/LICENSE.md +1 -1
- package/README.md +159 -296
- package/android/app/.gradle/config.properties +2 -0
- package/android/app/build.gradle +2 -0
- package/android/app/local.properties +8 -0
- package/android/app/src/main/AndroidManifest.xml +1 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +27 -21
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +5 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +5 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +14 -14
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +16 -9
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +1 -1
- package/android/build.gradle +3 -0
- package/android/codepush.gradle +3 -3
- package/docs/advanced-usage.md +56 -0
- package/docs/api-android.md +12 -75
- package/docs/api-ios.md +5 -17
- package/docs/api-js.md +18 -55
- package/docs/setup-android.md +15 -397
- package/docs/setup-ios.md +24 -198
- package/docs/setup-windows.md +7 -74
- package/ios/CodePush/CodePush.h +4 -4
- package/ios/CodePush/CodePush.m +10 -9
- package/ios/CodePush/CodePushConfig.m +14 -11
- package/ios/CodePush/CodePushPackage.m +60 -60
- package/ios/CodePush/CodePushTelemetryManager.m +13 -13
- package/ios/CodePush.xcodeproj/project.pbxproj +24 -470
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/package.json +27 -24
- package/react-native.config.js +1 -1
- package/scripts/generateBundledResourcesHash.js +1 -1
- package/scripts/getFilesInFolder.js +1 -1
- package/scripts/recordFilesBeforeBundleCommand.js +1 -1
- package/typings/react-native-code-push.d.ts +22 -22
- package/windows/CodePush/CodePushConfig.cpp +3 -3
- package/windows/CodePush/CodePushConfig.h +3 -3
- package/windows/CodePush/CodePushNativeModule.cpp +27 -27
- package/windows/CodePush/CodePushNativeModule.h +4 -4
- package/windows/CodePush/CodePushTelemetryManager.cpp +12 -12
- package/windows/CodePush/CodePushTelemetryManager.h +1 -1
- package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
- package/.azurepipelines/test-rn-code-push.yml +0 -94
- package/.config/CredScanSuppressions.json +0 -14
- package/SECURITY.md +0 -41
- package/docs/multi-deployment-testing-android.md +0 -148
- package/docs/multi-deployment-testing-ios.md +0 -59
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
- package/ios/CodePush/Base64/README.md +0 -47
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
- package/ios/CodePush/JWT/LICENSE +0 -19
- package/ios/CodePush/JWT/README.md +0 -489
- package/ios/CodePush/SSZipArchive/Common.h +0 -81
- package/ios/CodePush/SSZipArchive/README.md +0 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -76
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -691
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
- package/scripts/postlink/android/postlink.js +0 -87
- package/scripts/postlink/ios/postlink.js +0 -116
- package/scripts/postlink/run.js +0 -11
- package/scripts/postunlink/android/postunlink.js +0 -74
- package/scripts/postunlink/ios/postunlink.js +0 -87
- package/scripts/postunlink/run.js +0 -11
- package/scripts/tools/linkToolsAndroid.js +0 -57
- package/scripts/tools/linkToolsIos.js +0 -130
- package/windows-legacy/CodePush/CodePush.csproj +0 -128
- package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
- package/windows-legacy/CodePush/FileUtils.cs +0 -40
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
- package/windows-legacy/CodePush/UpdateManager.cs +0 -305
- package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
- package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
- package/windows-legacy/CodePush.Net46/packages.config +0 -5
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
- package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
- package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
- package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
- package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// MF_Base64Additions.m
|
|
3
|
-
// Base64 -- RFC 4648 compatible implementation
|
|
4
|
-
// see http://www.ietf.org/rfc/rfc4648.txt for more details
|
|
5
|
-
//
|
|
6
|
-
// Designed to be compiled with Automatic Reference Counting
|
|
7
|
-
//
|
|
8
|
-
// Created by Dave Poirier on 2012-06-14.
|
|
9
|
-
// Public Domain
|
|
10
|
-
// Hosted at https://github.com/ekscrypto/Base64
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
#import "MF_Base64Additions.h"
|
|
14
|
-
|
|
15
|
-
@implementation MF_Base64Codec
|
|
16
|
-
|
|
17
|
-
+(NSString *)base64StringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString
|
|
18
|
-
{
|
|
19
|
-
NSString *s = base64UrlEncodedString;
|
|
20
|
-
s = [s stringByReplacingOccurrencesOfString:@"-" withString:@"+"];
|
|
21
|
-
s = [s stringByReplacingOccurrencesOfString:@"_" withString:@"/"];
|
|
22
|
-
switch (s.length % 4) {
|
|
23
|
-
case 2:
|
|
24
|
-
s = [s stringByAppendingString:@"=="];
|
|
25
|
-
break;
|
|
26
|
-
case 3:
|
|
27
|
-
s = [s stringByAppendingString:@"="];
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
return s;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
+(NSString *)base64UrlEncodedStringFromBase64String:(NSString *)base64String
|
|
36
|
-
{
|
|
37
|
-
NSString *s = base64String;
|
|
38
|
-
s = [s stringByReplacingOccurrencesOfString:@"=" withString:@""];
|
|
39
|
-
s = [s stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
|
|
40
|
-
s = [s stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
|
|
41
|
-
return s;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
+(NSData *)dataFromBase64String:(NSString *)encoding
|
|
45
|
-
{
|
|
46
|
-
NSData *data = nil;
|
|
47
|
-
unsigned char *decodedBytes = NULL;
|
|
48
|
-
@try {
|
|
49
|
-
#define __ 255
|
|
50
|
-
static char decodingTable[256] = {
|
|
51
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x00 - 0x0F
|
|
52
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x10 - 0x1F
|
|
53
|
-
__,__,__,__, __,__,__,__, __,__,__,62, __,__,__,63, // 0x20 - 0x2F
|
|
54
|
-
52,53,54,55, 56,57,58,59, 60,61,__,__, __, 0,__,__, // 0x30 - 0x3F
|
|
55
|
-
__, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, // 0x40 - 0x4F
|
|
56
|
-
15,16,17,18, 19,20,21,22, 23,24,25,__, __,__,__,__, // 0x50 - 0x5F
|
|
57
|
-
__,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, // 0x60 - 0x6F
|
|
58
|
-
41,42,43,44, 45,46,47,48, 49,50,51,__, __,__,__,__, // 0x70 - 0x7F
|
|
59
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x80 - 0x8F
|
|
60
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0x90 - 0x9F
|
|
61
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xA0 - 0xAF
|
|
62
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xB0 - 0xBF
|
|
63
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xC0 - 0xCF
|
|
64
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xD0 - 0xDF
|
|
65
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xE0 - 0xEF
|
|
66
|
-
__,__,__,__, __,__,__,__, __,__,__,__, __,__,__,__, // 0xF0 - 0xFF
|
|
67
|
-
};
|
|
68
|
-
encoding = [encoding stringByReplacingOccurrencesOfString:@"=" withString:@""];
|
|
69
|
-
NSData *encodedData = [encoding dataUsingEncoding:NSASCIIStringEncoding];
|
|
70
|
-
unsigned char *encodedBytes = (unsigned char *)[encodedData bytes];
|
|
71
|
-
|
|
72
|
-
NSUInteger encodedLength = [encodedData length];
|
|
73
|
-
if( encodedLength >= (NSUIntegerMax - 3) ) return nil; // NSUInteger overflow check
|
|
74
|
-
NSUInteger encodedBlocks = (encodedLength+3) >> 2;
|
|
75
|
-
NSUInteger expectedDataLength = encodedBlocks * 3;
|
|
76
|
-
|
|
77
|
-
unsigned char decodingBlock[4];
|
|
78
|
-
|
|
79
|
-
decodedBytes = malloc(expectedDataLength);
|
|
80
|
-
if( decodedBytes != NULL ) {
|
|
81
|
-
|
|
82
|
-
NSUInteger i = 0;
|
|
83
|
-
NSUInteger j = 0;
|
|
84
|
-
NSUInteger k = 0;
|
|
85
|
-
unsigned char c;
|
|
86
|
-
while( i < encodedLength ) {
|
|
87
|
-
c = decodingTable[encodedBytes[i]];
|
|
88
|
-
i++;
|
|
89
|
-
if( c != __ ) {
|
|
90
|
-
decodingBlock[j] = c;
|
|
91
|
-
j++;
|
|
92
|
-
if( j == 4 ) {
|
|
93
|
-
decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
|
|
94
|
-
decodedBytes[k+1] = (decodingBlock[1] << 4) | (decodingBlock[2] >> 2);
|
|
95
|
-
decodedBytes[k+2] = (decodingBlock[2] << 6) | (decodingBlock[3]);
|
|
96
|
-
j = 0;
|
|
97
|
-
k += 3;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Process left over bytes, if any
|
|
103
|
-
if( j == 3 ) {
|
|
104
|
-
decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
|
|
105
|
-
decodedBytes[k+1] = (decodingBlock[1] << 4) | (decodingBlock[2] >> 2);
|
|
106
|
-
k += 2;
|
|
107
|
-
} else if( j == 2 ) {
|
|
108
|
-
decodedBytes[k] = (decodingBlock[0] << 2) | (decodingBlock[1] >> 4);
|
|
109
|
-
k += 1;
|
|
110
|
-
}
|
|
111
|
-
data = [[NSData alloc] initWithBytes:decodedBytes length:k];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
@catch (NSException *exception) {
|
|
115
|
-
data = nil;
|
|
116
|
-
NSLog(@"WARNING: error occured while decoding base 32 string: %@", exception);
|
|
117
|
-
}
|
|
118
|
-
@finally {
|
|
119
|
-
if( decodedBytes != NULL ) {
|
|
120
|
-
free( decodedBytes );
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return data;
|
|
124
|
-
}
|
|
125
|
-
+(NSString *)base64StringFromData:(NSData *)data
|
|
126
|
-
{
|
|
127
|
-
NSString *encoding = nil;
|
|
128
|
-
unsigned char *encodingBytes = NULL;
|
|
129
|
-
@try {
|
|
130
|
-
static char encodingTable[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
131
|
-
static NSUInteger paddingTable[] = {0,2,1};
|
|
132
|
-
// Table 1: The Base 64 Alphabet
|
|
133
|
-
//
|
|
134
|
-
// Value Encoding Value Encoding Value Encoding Value Encoding
|
|
135
|
-
// 0 A 17 R 34 i 51 z
|
|
136
|
-
// 1 B 18 S 35 j 52 0
|
|
137
|
-
// 2 C 19 T 36 k 53 1
|
|
138
|
-
// 3 D 20 U 37 l 54 2
|
|
139
|
-
// 4 E 21 V 38 m 55 3
|
|
140
|
-
// 5 F 22 W 39 n 56 4
|
|
141
|
-
// 6 G 23 X 40 o 57 5
|
|
142
|
-
// 7 H 24 Y 41 p 58 6
|
|
143
|
-
// 8 I 25 Z 42 q 59 7
|
|
144
|
-
// 9 J 26 a 43 r 60 8
|
|
145
|
-
// 10 K 27 b 44 s 61 9
|
|
146
|
-
// 11 L 28 c 45 t 62 +
|
|
147
|
-
// 12 M 29 d 46 u 63 /
|
|
148
|
-
// 13 N 30 e 47 v
|
|
149
|
-
// 14 O 31 f 48 w (pad) =
|
|
150
|
-
// 15 P 32 g 49 x
|
|
151
|
-
// 16 Q 33 h 50 y
|
|
152
|
-
|
|
153
|
-
NSUInteger dataLength = [data length];
|
|
154
|
-
NSUInteger encodedBlocks = dataLength / 3;
|
|
155
|
-
if( (encodedBlocks + 1) >= (NSUIntegerMax / 4) ) return nil; // NSUInteger overflow check
|
|
156
|
-
NSUInteger padding = paddingTable[dataLength % 3];
|
|
157
|
-
if( padding > 0 ) encodedBlocks++;
|
|
158
|
-
NSUInteger encodedLength = encodedBlocks * 4;
|
|
159
|
-
|
|
160
|
-
encodingBytes = malloc(encodedLength);
|
|
161
|
-
if( encodingBytes != NULL ) {
|
|
162
|
-
NSUInteger rawBytesToProcess = dataLength;
|
|
163
|
-
NSUInteger rawBaseIndex = 0;
|
|
164
|
-
NSUInteger encodingBaseIndex = 0;
|
|
165
|
-
unsigned char *rawBytes = (unsigned char *)[data bytes];
|
|
166
|
-
unsigned char rawByte1, rawByte2, rawByte3;
|
|
167
|
-
while( rawBytesToProcess >= 3 ) {
|
|
168
|
-
rawByte1 = rawBytes[rawBaseIndex];
|
|
169
|
-
rawByte2 = rawBytes[rawBaseIndex+1];
|
|
170
|
-
rawByte3 = rawBytes[rawBaseIndex+2];
|
|
171
|
-
encodingBytes[encodingBaseIndex] = encodingTable[((rawByte1 >> 2) & 0x3F)];
|
|
172
|
-
encodingBytes[encodingBaseIndex+1] = encodingTable[((rawByte1 << 4) & 0x30) | ((rawByte2 >> 4) & 0x0F) ];
|
|
173
|
-
encodingBytes[encodingBaseIndex+2] = encodingTable[((rawByte2 << 2) & 0x3C) | ((rawByte3 >> 6) & 0x03) ];
|
|
174
|
-
encodingBytes[encodingBaseIndex+3] = encodingTable[(rawByte3 & 0x3F)];
|
|
175
|
-
|
|
176
|
-
rawBaseIndex += 3;
|
|
177
|
-
encodingBaseIndex += 4;
|
|
178
|
-
rawBytesToProcess -= 3;
|
|
179
|
-
}
|
|
180
|
-
rawByte2 = 0;
|
|
181
|
-
switch (dataLength-rawBaseIndex) {
|
|
182
|
-
case 2:
|
|
183
|
-
rawByte2 = rawBytes[rawBaseIndex+1];
|
|
184
|
-
case 1:
|
|
185
|
-
rawByte1 = rawBytes[rawBaseIndex];
|
|
186
|
-
encodingBytes[encodingBaseIndex] = encodingTable[((rawByte1 >> 2) & 0x3F)];
|
|
187
|
-
encodingBytes[encodingBaseIndex+1] = encodingTable[((rawByte1 << 4) & 0x30) | ((rawByte2 >> 4) & 0x0F) ];
|
|
188
|
-
encodingBytes[encodingBaseIndex+2] = encodingTable[((rawByte2 << 2) & 0x3C) ];
|
|
189
|
-
// we can skip rawByte3 since we have a partial block it would always be 0
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
// compute location from where to begin inserting padding, it may overwrite some bytes from the partial block encoding
|
|
193
|
-
// if their value was 0 (cases 1-2).
|
|
194
|
-
encodingBaseIndex = encodedLength - padding;
|
|
195
|
-
while( padding-- > 0 ) {
|
|
196
|
-
encodingBytes[encodingBaseIndex++] = '=';
|
|
197
|
-
}
|
|
198
|
-
encoding = [[NSString alloc] initWithBytes:encodingBytes length:encodedLength encoding:NSASCIIStringEncoding];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
@catch (NSException *exception) {
|
|
202
|
-
encoding = nil;
|
|
203
|
-
NSLog(@"WARNING: error occured while tring to encode base 32 data: %@", exception);
|
|
204
|
-
}
|
|
205
|
-
@finally {
|
|
206
|
-
if( encodingBytes != NULL ) {
|
|
207
|
-
free( encodingBytes );
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return encoding;
|
|
211
|
-
}
|
|
212
|
-
@end
|
|
213
|
-
|
|
214
|
-
@implementation NSString (Base64Addition)
|
|
215
|
-
-(NSString *)base64String
|
|
216
|
-
{
|
|
217
|
-
NSData *utf8encoding = [self dataUsingEncoding:NSUTF8StringEncoding];
|
|
218
|
-
return [MF_Base64Codec base64StringFromData:utf8encoding];
|
|
219
|
-
}
|
|
220
|
-
-(NSString *)base64UrlEncodedString
|
|
221
|
-
{
|
|
222
|
-
return [MF_Base64Codec base64UrlEncodedStringFromBase64String:[self base64String]];
|
|
223
|
-
}
|
|
224
|
-
+(NSString *)stringFromBase64String:(NSString *)base64String
|
|
225
|
-
{
|
|
226
|
-
NSData *utf8encoding = [MF_Base64Codec dataFromBase64String:base64String];
|
|
227
|
-
return [[NSString alloc] initWithData:utf8encoding encoding:NSUTF8StringEncoding];
|
|
228
|
-
}
|
|
229
|
-
+(NSString *)stringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString
|
|
230
|
-
{
|
|
231
|
-
return [self stringFromBase64String:[MF_Base64Codec base64StringFromBase64UrlEncodedString:base64UrlEncodedString]];
|
|
232
|
-
}
|
|
233
|
-
@end
|
|
234
|
-
|
|
235
|
-
@implementation NSData (Base64Addition)
|
|
236
|
-
+(NSData *)dataWithBase64String:(NSString *)base64String
|
|
237
|
-
{
|
|
238
|
-
return [MF_Base64Codec dataFromBase64String:base64String];
|
|
239
|
-
}
|
|
240
|
-
+(NSData *)dataWithBase64UrlEncodedString:(NSString *)base64UrlEncodedString
|
|
241
|
-
{
|
|
242
|
-
return [self dataWithBase64String:[MF_Base64Codec base64StringFromBase64UrlEncodedString:base64UrlEncodedString]];
|
|
243
|
-
}
|
|
244
|
-
-(NSString *)base64String
|
|
245
|
-
{
|
|
246
|
-
return [MF_Base64Codec base64StringFromData:self];
|
|
247
|
-
}
|
|
248
|
-
-(NSString *)base64UrlEncodedString
|
|
249
|
-
{
|
|
250
|
-
return [MF_Base64Codec base64UrlEncodedStringFromBase64String:[self base64String]];
|
|
251
|
-
}
|
|
252
|
-
@end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
[](https://github.com/ekscrypto/Base64)
|
|
2
|
-
|
|
3
|
-
Base64 Additions for Objective-C on Mac OS X and iOS
|
|
4
|
-
=======
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Usage
|
|
8
|
-
----
|
|
9
|
-
Open the Xcode project file, and drag MF_Base64Additions.m/.h into your project.
|
|
10
|
-
|
|
11
|
-
In files where you want to use Base64 encoding/decoding, simply include the header file and use one of the provided NSData or NSString additions.
|
|
12
|
-
|
|
13
|
-
Example use:
|
|
14
|
-
#import "MF_Base64Additions.h"
|
|
15
|
-
|
|
16
|
-
NSString *helloWorld = @"Hello World";
|
|
17
|
-
NSString *helloInBase64 = [helloWorld base64String];
|
|
18
|
-
NSString *helloDecoded = [NSString stringFromBase64String:helloInBase64];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Performance
|
|
24
|
-
----
|
|
25
|
-
* Encoding: Approximately 4 to 5 times faster than using the equivalent SecTransform.
|
|
26
|
-
* Encoding: 30% faster than https://github.com/l4u/NSData-Base64
|
|
27
|
-
* Decoding: 5% faster than using the equivalent SecTransform.
|
|
28
|
-
* Decoding: 5% faster than https://github.com/l4u/NSData-Base64
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Requirements
|
|
33
|
-
-----
|
|
34
|
-
* Compile with Automatic Reference Counting
|
|
35
|
-
* Compatible with Mac OSX 10.6+ and iOS 4.0+
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Implementation
|
|
40
|
-
----
|
|
41
|
-
* Implemented as per RFC 4648, see http://www.ietf.org/rfc/rfc4648.txt for more details.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Licensing
|
|
46
|
-
----
|
|
47
|
-
* Public Domain
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithm.h
|
|
3
|
-
// JWT
|
|
4
|
-
//
|
|
5
|
-
// Created by Klaas Pieter Annema on 31-05-13.
|
|
6
|
-
// Copyright (c) 2013 Karma. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import "JWTDeprecations.h"
|
|
11
|
-
|
|
12
|
-
@protocol JWTAlgorithm <NSObject>
|
|
13
|
-
|
|
14
|
-
@required
|
|
15
|
-
/**
|
|
16
|
-
Signs data using provided secret data.
|
|
17
|
-
@param hash The data to sign.
|
|
18
|
-
@param key The secret to use for signing.
|
|
19
|
-
@param error The inout error.
|
|
20
|
-
*/
|
|
21
|
-
- (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing*)error;
|
|
22
|
-
/**
|
|
23
|
-
Verifies data using.
|
|
24
|
-
@param hash The data to sign.
|
|
25
|
-
@param signature The secret to use for signing.
|
|
26
|
-
@param error The inout error.
|
|
27
|
-
*/
|
|
28
|
-
- (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing*)error;
|
|
29
|
-
|
|
30
|
-
//@required
|
|
31
|
-
|
|
32
|
-
@property (nonatomic, readonly, copy) NSString *name;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
Encodes and encrypts the provided payload using the provided secret key
|
|
36
|
-
@param theString The string to encode
|
|
37
|
-
@param theSecret The secret to use for encryption
|
|
38
|
-
@return An NSData object containing the encrypted payload, or nil if something went wrong.
|
|
39
|
-
*/
|
|
40
|
-
- (NSData *)encodePayload:(NSString *)theString withSecret:(NSString *)theSecret __deprecated_and_will_be_removed_in_release_version(JWTVersion_3_0_0);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
Verifies the provided signature using the signed input and verification key
|
|
44
|
-
@param input The header and payload encoded string
|
|
45
|
-
@param signature The JWT provided signature
|
|
46
|
-
@param verificationKey The key to use for verifying the signature
|
|
47
|
-
@return YES if the provided signature is valid, NO otherwise
|
|
48
|
-
*/
|
|
49
|
-
- (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKey:(NSString *)verificationKey __deprecated_and_will_be_removed_in_release_version(JWTVersion_3_0_0);
|
|
50
|
-
|
|
51
|
-
@optional
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
Encodes and encrypts the provided payload using the provided secret key
|
|
55
|
-
@param theStringData The data to encode
|
|
56
|
-
@param theSecretData The secret data to use for encryption
|
|
57
|
-
@return An NSData object containing the encrypted payload, or nil if something went wrong.
|
|
58
|
-
*/
|
|
59
|
-
- (NSData *)encodePayloadData:(NSData *)theStringData withSecret:(NSData *)theSecretData;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
Verifies the provided signature using the signed input and verification key (as data)
|
|
63
|
-
@param input The header and payload encoded string
|
|
64
|
-
@param signature The JWT provided signature
|
|
65
|
-
@param verificationKeyData The key data to use for verifying the signature
|
|
66
|
-
@return YES if the provided signature is valid, NO otherwise
|
|
67
|
-
*/
|
|
68
|
-
- (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKeyData:(NSData *)verificationKeyData;
|
|
69
|
-
@end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmFactory.h
|
|
3
|
-
// JWT
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 07.10.15.
|
|
6
|
-
// Copyright © 2015 Karma. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import "JWTAlgorithm.h"
|
|
11
|
-
@interface JWTAlgorithmFactory : NSObject
|
|
12
|
-
|
|
13
|
-
+ (NSArray *)algorithms;
|
|
14
|
-
+ (id<JWTAlgorithm>)algorithmByName:(NSString *)name;
|
|
15
|
-
|
|
16
|
-
@end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmFactory.m
|
|
3
|
-
// JWT
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 07.10.15.
|
|
6
|
-
// Copyright © 2015 Karma. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "JWTAlgorithmFactory.h"
|
|
10
|
-
#import "JWTAlgorithmHSBase.h"
|
|
11
|
-
#import "JWTAlgorithmRSBase.h"
|
|
12
|
-
#import "JWTAlgorithmNone.h"
|
|
13
|
-
|
|
14
|
-
// not implemented.
|
|
15
|
-
NSString *const JWTAlgorithmNameES256 = @"ES256";
|
|
16
|
-
NSString *const JWTAlgorithmNameES384 = @"ES384";
|
|
17
|
-
NSString *const JWTAlgorithmNameES512 = @"ES512";
|
|
18
|
-
|
|
19
|
-
@implementation JWTAlgorithmFactory
|
|
20
|
-
|
|
21
|
-
+ (NSArray *)algorithms {
|
|
22
|
-
return @[
|
|
23
|
-
[JWTAlgorithmNone new],
|
|
24
|
-
[JWTAlgorithmHSBase algorithm256],
|
|
25
|
-
[JWTAlgorithmHSBase algorithm384],
|
|
26
|
-
[JWTAlgorithmHSBase algorithm512],
|
|
27
|
-
[JWTAlgorithmRSBase algorithm256],
|
|
28
|
-
[JWTAlgorithmRSBase algorithm384],
|
|
29
|
-
[JWTAlgorithmRSBase algorithm512]
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
+ (id<JWTAlgorithm>)algorithmByName:(NSString *)name {
|
|
35
|
-
id<JWTAlgorithm> algorithm = nil;
|
|
36
|
-
|
|
37
|
-
NSString *algName = [name copy];
|
|
38
|
-
|
|
39
|
-
NSUInteger index = [[self algorithms] indexOfObjectPassingTest:^BOOL(id<JWTAlgorithm> obj, NSUInteger idx, BOOL *stop) {
|
|
40
|
-
// lowercase comparison
|
|
41
|
-
return [obj.name.lowercaseString isEqualToString:algName.lowercaseString];
|
|
42
|
-
}];
|
|
43
|
-
|
|
44
|
-
if (index != NSNotFound) {
|
|
45
|
-
algorithm = [self algorithms][index];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return algorithm;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmNone.h
|
|
3
|
-
// JWT
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 16.10.15.
|
|
6
|
-
// Copyright © 2015 Karma. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import "JWTAlgorithm.h"
|
|
11
|
-
extern NSString *const JWTAlgorithmNameNone;
|
|
12
|
-
|
|
13
|
-
@interface JWTAlgorithmNone : NSObject <JWTAlgorithm>
|
|
14
|
-
|
|
15
|
-
@end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmNone.m
|
|
3
|
-
// JWT
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 16.10.15.
|
|
6
|
-
// Copyright © 2015 Karma. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "JWTAlgorithmNone.h"
|
|
10
|
-
NSString *const JWTAlgorithmNameNone = @"none";
|
|
11
|
-
|
|
12
|
-
@implementation JWTAlgorithmNone
|
|
13
|
-
|
|
14
|
-
- (NSString *)name {
|
|
15
|
-
return JWTAlgorithmNameNone;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
- (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing *)error {
|
|
19
|
-
return [NSData data];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
- (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing *)error {
|
|
23
|
-
//if a secret is provided, this isn't the None algorithm
|
|
24
|
-
if (key && key.length > 0) {
|
|
25
|
-
return NO;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//If the signature isn't blank, this isn't the None algorithm
|
|
29
|
-
if (signature && signature.length > 0) {
|
|
30
|
-
return NO;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return YES;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
- (NSData *)encodePayload:(NSString *)theString withSecret:(NSString *)theSecret {
|
|
37
|
-
return [self encodePayloadData:[theSecret dataUsingEncoding:NSUTF8StringEncoding] withSecret:[theSecret dataUsingEncoding:NSUTF8StringEncoding]];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
- (NSData *)encodePayloadData:(NSData *)theStringData withSecret:(NSData *)theSecretData
|
|
41
|
-
{
|
|
42
|
-
return [self signHash:theStringData key:theSecretData error:nil];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
- (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKey:(NSString *)verificationKey
|
|
46
|
-
{
|
|
47
|
-
return [self verifySignedInput:input withSignature:signature verificationKeyData:verificationKey];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
- (BOOL)verifySignedInput:(NSString *)input withSignature:(NSString *)signature verificationKeyData:(NSData *)verificationKeyData
|
|
51
|
-
{
|
|
52
|
-
return [self verifyHash:[input dataUsingEncoding:NSUTF8StringEncoding] signature:[signature dataUsingEncoding:NSUTF8StringEncoding] key:verificationKeyData error:nil];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmESBase.h
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 12.02.17.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import "JWTRSAlgorithm.h"
|
|
11
|
-
extern NSString *const JWTAlgorithmNameES256;
|
|
12
|
-
extern NSString *const JWTAlgorithmNameES384;
|
|
13
|
-
extern NSString *const JWTAlgorithmNameES512;
|
|
14
|
-
@interface JWTAlgorithmESBase : NSObject @end
|
|
15
|
-
|
|
16
|
-
@interface JWTAlgorithmESBase (JWTAsymmetricKeysAlgorithm) <JWTAsymmetricKeysAlgorithm> @end
|
|
17
|
-
|
|
18
|
-
@interface JWTAlgorithmESBase (Create)
|
|
19
|
-
|
|
20
|
-
+ (instancetype)algorithm256;
|
|
21
|
-
+ (instancetype)algorithm384;
|
|
22
|
-
+ (instancetype)algorithm512;
|
|
23
|
-
|
|
24
|
-
@end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmESBase.m
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by Lobanov Dmitry on 12.02.17.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "JWTAlgorithmESBase.h"
|
|
10
|
-
#import <CommonCrypto/CommonCryptor.h>
|
|
11
|
-
@interface JWTAlgorithmESBase ()
|
|
12
|
-
|
|
13
|
-
@end
|
|
14
|
-
@implementation JWTAlgorithmESBase
|
|
15
|
-
@synthesize keyExtractorType;
|
|
16
|
-
@synthesize signKey;
|
|
17
|
-
@synthesize verifyKey;
|
|
18
|
-
@end
|
|
19
|
-
|
|
20
|
-
// thanks! https://github.com/soyersoyer/SwCrypt
|
|
21
|
-
@interface JWTAlgorithmESBase (ImportKeys)
|
|
22
|
-
- (void)importKey;
|
|
23
|
-
//importKey(publicKey, format: .importKeyBinary, keyType: .keyPublic)
|
|
24
|
-
@end
|
|
25
|
-
@implementation JWTAlgorithmESBase (ImportKeys)
|
|
26
|
-
- (void)importKey {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
@end
|
|
30
|
-
|
|
31
|
-
@implementation JWTAlgorithmESBase (JWTAsymmetricKeysAlgorithm)
|
|
32
|
-
- (NSString *)name {
|
|
33
|
-
return @"ESBase";
|
|
34
|
-
}
|
|
35
|
-
- (NSData *)signHash:(NSData *)hash key:(NSData *)key error:(NSError *__autoreleasing *)error {
|
|
36
|
-
return nil;
|
|
37
|
-
}
|
|
38
|
-
- (BOOL)verifyHash:(NSData *)hash signature:(NSData *)signature key:(NSData *)key error:(NSError *__autoreleasing *)error {
|
|
39
|
-
return NO;
|
|
40
|
-
}
|
|
41
|
-
@end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// JWTAlgorithmHSBase.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 "JWTAlgorithm.h"
|
|
11
|
-
extern NSString *const JWTAlgorithmNameHS256;
|
|
12
|
-
extern NSString *const JWTAlgorithmNameHS384;
|
|
13
|
-
extern NSString *const JWTAlgorithmNameHS512;
|
|
14
|
-
|
|
15
|
-
@interface JWTAlgorithmHSBase : NSObject <JWTAlgorithm>
|
|
16
|
-
|
|
17
|
-
@property (assign, nonatomic, readonly) size_t ccSHANumberDigestLength;
|
|
18
|
-
@property (assign, nonatomic, readonly) uint32_t ccHmacAlgSHANumber;
|
|
19
|
-
|
|
20
|
-
@end
|
|
21
|
-
|
|
22
|
-
@interface JWTAlgorithmHSBase (Create)
|
|
23
|
-
|
|
24
|
-
+ (instancetype)algorithm256;
|
|
25
|
-
+ (instancetype)algorithm384;
|
|
26
|
-
+ (instancetype)algorithm512;
|
|
27
|
-
|
|
28
|
-
@end
|