Skip to content

Commit 1516be2

Browse files
authored
Renaming CryptorModule with CryptoModule (#145)
PubNub SDK 6.2.1 release
1 parent 56c8687 commit 1516be2

22 files changed

+140
-125
lines changed

.pubnub.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
---
22
name: swift
33
scm: github.com/pubnub/swift
4-
version: "6.2.0"
4+
version: "6.2.1"
55
schema: 1
66
changelog:
7+
- date: 2023-10-23
8+
version: 6.2.1
9+
changes:
10+
- type: bug
11+
text: "Align on namings across all supported platforms."
712
- date: 2023-10-16
813
version: v6.2.0
914
changes:
@@ -497,7 +502,7 @@ sdks:
497502
- distribution-type: source
498503
distribution-repository: GitHub release
499504
package-name: PubNub
500-
location: https://github.com/pubnub/swift/archive/refs/tags/6.2.0.zip
505+
location: https://github.com/pubnub/swift/archive/refs/tags/6.2.1.zip
501506
supported-platforms:
502507
supported-operating-systems:
503508
macOS:

Examples/Sources/ConfigDetailTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ConfigDetailTableViewController: UITableViewController {
9090
case .subscribeKey:
9191
return config.subscribeKey
9292
case .cipherKey:
93-
return config.cryptorModule?.description ?? "CryptorModule Not Found"
93+
return config.cryptoModule?.description ?? "CryptoModule Not Found"
9494
case .authKey:
9595
return config.authKey
9696
case .uuid:

PubNub.xcodeproj/project.pbxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376
35FE941B22EFE5400051C455 /* EventStreamTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35FE941A22EFE5400051C455 /* EventStreamTests.swift */; };
377377
35FE941F22F0929A0051C455 /* RequestRetrierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35FE941E22F0929A0051C455 /* RequestRetrierTests.swift */; };
378378
3D6265D72ABCA79100FDD5E6 /* CryptorUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D6265D62ABCA79100FDD5E6 /* CryptorUtils.swift */; };
379-
3D758DBF2AAA1C49005D2B36 /* CryptorModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DBE2AAA1C49005D2B36 /* CryptorModule.swift */; };
379+
3D758DBF2AAA1C49005D2B36 /* CryptoModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DBE2AAA1C49005D2B36 /* CryptoModule.swift */; };
380380
3D758DC82AB06A12005D2B36 /* CryptoInputStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DC62AB06A12005D2B36 /* CryptoInputStream.swift */; };
381381
3D758DC92AB06A12005D2B36 /* CryptoStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DC72AB06A12005D2B36 /* CryptoStream.swift */; };
382382
3D758DCB2AB06A2D005D2B36 /* Cryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DCA2AB06A2D005D2B36 /* Cryptor.swift */; };
@@ -911,7 +911,7 @@
911911
35FE941A22EFE5400051C455 /* EventStreamTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventStreamTests.swift; sourceTree = "<group>"; };
912912
35FE941E22F0929A0051C455 /* RequestRetrierTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestRetrierTests.swift; sourceTree = "<group>"; };
913913
3D6265D62ABCA79100FDD5E6 /* CryptorUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptorUtils.swift; sourceTree = "<group>"; };
914-
3D758DBE2AAA1C49005D2B36 /* CryptorModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptorModule.swift; sourceTree = "<group>"; };
914+
3D758DBE2AAA1C49005D2B36 /* CryptoModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoModule.swift; sourceTree = "<group>"; };
915915
3D758DC62AB06A12005D2B36 /* CryptoInputStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptoInputStream.swift; sourceTree = "<group>"; };
916916
3D758DC72AB06A12005D2B36 /* CryptoStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptoStream.swift; sourceTree = "<group>"; };
917917
3D758DCA2AB06A2D005D2B36 /* Cryptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cryptor.swift; sourceTree = "<group>"; };
@@ -1091,7 +1091,7 @@
10911091
isa = PBXGroup;
10921092
children = (
10931093
3595120F2301DCAB00C9D3AE /* Crypto.swift */,
1094-
3D758DBE2AAA1C49005D2B36 /* CryptorModule.swift */,
1094+
3D758DBE2AAA1C49005D2B36 /* CryptoModule.swift */,
10951095
3D758DCC2AB06B98005D2B36 /* Header */,
10961096
3D758DC52AB06983005D2B36 /* Cryptors */,
10971097
3D758DC42AB06977005D2B36 /* Miscellaneous */,
@@ -3078,7 +3078,7 @@
30783078
35D0615F2304830600FDB2F9 /* GenericServicePayloadResponse.swift in Sources */,
30793079
3D758DD62AB48A6A005D2B36 /* CryptorHeaderWithinStreamFinder.swift in Sources */,
30803080
35A66A8E22F911DB00AC67A9 /* SubscribeSessionFactory.swift in Sources */,
3081-
3D758DBF2AAA1C49005D2B36 /* CryptorModule.swift in Sources */,
3081+
3D758DBF2AAA1C49005D2B36 /* CryptoModule.swift in Sources */,
30823082
3D758DD02AB0A8C6005D2B36 /* CryptorVector.swift in Sources */,
30833083
3D6265D72ABCA79100FDD5E6 /* CryptorUtils.swift in Sources */,
30843084
35D8D4C522EB4600001B07D9 /* AnyJSON.swift in Sources */,
@@ -3436,7 +3436,7 @@
34363436
"@executable_path/Frameworks",
34373437
"@loader_path/Frameworks",
34383438
);
3439-
MARKETING_VERSION = 6.2.0;
3439+
MARKETING_VERSION = 6.2.1;
34403440
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
34413441
MTL_FAST_MATH = YES;
34423442
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubUser;
@@ -3483,7 +3483,7 @@
34833483
"@executable_path/Frameworks",
34843484
"@loader_path/Frameworks",
34853485
);
3486-
MARKETING_VERSION = 6.2.0;
3486+
MARKETING_VERSION = 6.2.1;
34873487
MTL_ENABLE_DEBUG_INFO = NO;
34883488
MTL_FAST_MATH = YES;
34893489
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubUser;
@@ -3583,7 +3583,7 @@
35833583
"@executable_path/Frameworks",
35843584
"@loader_path/Frameworks",
35853585
);
3586-
MARKETING_VERSION = 6.2.0;
3586+
MARKETING_VERSION = 6.2.1;
35873587
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
35883588
MTL_FAST_MATH = YES;
35893589
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubSpace;
@@ -3632,7 +3632,7 @@
36323632
"@executable_path/Frameworks",
36333633
"@loader_path/Frameworks",
36343634
);
3635-
MARKETING_VERSION = 6.2.0;
3635+
MARKETING_VERSION = 6.2.1;
36363636
MTL_ENABLE_DEBUG_INFO = NO;
36373637
MTL_FAST_MATH = YES;
36383638
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubSpace;
@@ -3745,7 +3745,7 @@
37453745
"@executable_path/Frameworks",
37463746
"@loader_path/Frameworks",
37473747
);
3748-
MARKETING_VERSION = 6.2.0;
3748+
MARKETING_VERSION = 6.2.1;
37493749
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
37503750
MTL_FAST_MATH = YES;
37513751
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubMembership;
@@ -3793,7 +3793,7 @@
37933793
"@executable_path/Frameworks",
37943794
"@loader_path/Frameworks",
37953795
);
3796-
MARKETING_VERSION = 6.2.0;
3796+
MARKETING_VERSION = 6.2.1;
37973797
MTL_ENABLE_DEBUG_INFO = NO;
37983798
MTL_FAST_MATH = YES;
37993799
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubMembership;
@@ -4253,7 +4253,7 @@
42534253
"$(inherited)",
42544254
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
42554255
);
4256-
MARKETING_VERSION = 6.2.0;
4256+
MARKETING_VERSION = 6.2.1;
42574257
OTHER_CFLAGS = "$(inherited)";
42584258
OTHER_LDFLAGS = "$(inherited)";
42594259
OTHER_SWIFT_FLAGS = "$(inherited)";
@@ -4292,7 +4292,7 @@
42924292
"$(inherited)",
42934293
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
42944294
);
4295-
MARKETING_VERSION = 6.2.0;
4295+
MARKETING_VERSION = 6.2.1;
42964296
OTHER_CFLAGS = "$(inherited)";
42974297
OTHER_LDFLAGS = "$(inherited)";
42984298
OTHER_SWIFT_FLAGS = "$(inherited)";

PubNubSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'PubNubSwift'
3-
s.version = '6.2.0'
3+
s.version = '6.2.1'
44
s.homepage = 'https://github.com/pubnub/swift'
55
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
66
s.authors = { 'PubNub, Inc.' => '[email protected]' }

Sources/PubNub/APIs/File+PubNub.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public extension PubNub {
160160
switch result {
161161
case let .success(response):
162162
do {
163-
let cryptorModule = requestConfig.customConfiguration?.cryptorModule ?? configuration.cryptorModule
163+
let cryptoModule = requestConfig.customConfiguration?.cryptoModule ?? configuration.cryptoModule
164164
completion?(.success((
165-
try URLRequest(from: response.payload, uploading: content, cryptorModule: cryptorModule),
165+
try URLRequest(from: response.payload, uploading: content, cryptoModule: cryptoModule),
166166
response.payload.fileId,
167167
response.payload.filename
168168
)))
@@ -450,7 +450,7 @@ public extension PubNub {
450450
/// - downloadTo: The async `Result` of the method call
451451
/// - Returns: The new file download task. The `urlSessionTask` property can be used to access the underlying `URLSessionDownloadTask`
452452
func createFileURLSessionDownloadTask(
453-
_ taskType: FileDownloadTaskType, session: URLSessionReplaceable, downloadTo url: URL, decrypt: CryptorModule? = nil
453+
_ taskType: FileDownloadTaskType, session: URLSessionReplaceable, downloadTo url: URL, decrypt: CryptoModule? = nil
454454
) -> HTTPFileDownloadTask {
455455
let downloadTask: URLSessionDownloadTask
456456
switch taskType {
@@ -464,7 +464,7 @@ public extension PubNub {
464464
task: downloadTask,
465465
session: session.configuration.identifier,
466466
downloadTo: url,
467-
cryptorModule: decrypt ?? configuration.cryptorModule
467+
cryptoModule: decrypt ?? configuration.cryptoModule
468468
)
469469

470470
// Create task map inside Delegate

Sources/PubNub/Extensions/URLRequest+PubNub.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public extension URLRequest {
4646
internal init(
4747
from response: GenerateUploadURLResponse,
4848
uploading content: PubNub.FileUploadContent,
49-
cryptorModule: CryptorModule? = nil
49+
cryptoModule: CryptoModule? = nil
5050
) throws {
5151
self.init(url: response.uploadRequestURL)
5252
method = response.uploadMethod
@@ -73,8 +73,8 @@ public extension URLRequest {
7373
let contentLength: Int
7474

7575
// If we were given a Crypto module we should convert the stream to a secure stream
76-
if let cryptorModule = cryptorModule {
77-
switch cryptorModule.encrypt(stream: contentStream, contentLength: content.contentLength) {
76+
if let cryptoModule = cryptoModule {
77+
switch cryptoModule.encrypt(stream: contentStream, contentLength: content.contentLength) {
7878
case .success(let encryptingResult):
7979
finalStream = encryptingResult
8080
contentLength = prefixData.count + ((encryptingResult as? MultipartInputStream)?.length ?? 0) + postfixData.count

Sources/PubNub/Helpers/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public enum Constant {
5757

5858
static let pubnubSwiftSDKName: String = "PubNubSwift"
5959

60-
static let pubnubSwiftSDKVersion: String = "6.2.0"
60+
static let pubnubSwiftSDKVersion: String = "6.2.1"
6161

6262
static let appBundleId: String = {
6363
if let info = Bundle.main.infoDictionary,

Sources/PubNub/Helpers/Crypto/Crypto.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Foundation
3030

3131
/// Object capable of encryption/decryption
3232
///
33-
/// - Warning: This struct is deprecated. Use ``CryptorModule`` instead.
33+
/// - Warning: This struct is deprecated. Use ``CryptoModule`` instead.
3434
public struct Crypto: Hashable {
3535
/// Key initially provided by the user
3636
let key: String

Sources/PubNub/Helpers/Crypto/CryptorModule.swift renamed to Sources/PubNub/Helpers/Crypto/CryptoModule.swift

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// CryptorModule.swift
2+
// CryptoModule.swift
33
//
44
// PubNub Real-time Cloud-Hosted Push API and Push Notification Client Frameworks
55
// Copyright © 2023 PubNub Inc.
@@ -27,19 +27,29 @@
2727

2828
import Foundation
2929

30+
@available(*, unavailable, renamed: "CryptoModule")
31+
public class CryptorModule {
32+
public static func aesCbcCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptoModule {
33+
preconditionFailure("This method is no longer available")
34+
}
35+
public static func legacyCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptoModule {
36+
preconditionFailure("This method is no longer available")
37+
}
38+
}
39+
3040
/// Object capable of encryption/decryption
31-
public struct CryptorModule {
41+
public struct CryptoModule {
3242
private let defaultCryptor: Cryptor
3343
private let cryptors: [Cryptor]
3444
private let legacyCryptorId: CryptorId = []
3545

3646
typealias Base64EncodedString = String
3747

38-
/// Initializes `CryptorModule` with custom ``Cryptor`` objects capable of encryption and decryption
48+
/// Initializes `CryptoModule` with custom ``Cryptor`` objects capable of encryption and decryption
3949
///
4050
/// Use this constructor if you would like to provide **custom** objects for decryption and encryption and don't want to use PubNub's built-in `Cryptors`.
4151
/// Otherwise, refer to convenience static factory methods such as ``aesCbcCryptoModule(with:withRandomIV:)``
42-
/// and ``legacyCryptoModule(with:withRandomIV:)`` that return `CryptorModule` configured for you.
52+
/// and ``legacyCryptoModule(with:withRandomIV:)`` that return `CryptoModule` configured for you.
4353
///
4454
/// - Parameters:
4555
/// - default: Primary ``Cryptor`` instance used for encryption and decryption
@@ -251,10 +261,10 @@ public struct CryptorModule {
251261
}
252262
}
253263

254-
/// Convenience methods for creating `CryptorModule`
255-
public extension CryptorModule {
264+
/// Convenience methods for creating `CryptoModule`
265+
public extension CryptoModule {
256266

257-
/// Returns **recommended** `CryptorModule` for encryption/decryption
267+
/// Returns **recommended** `CryptoModule` for encryption/decryption
258268
///
259269
/// - Parameters:
260270
/// - key: Key used for encryption/decryption
@@ -263,40 +273,40 @@ public extension CryptorModule {
263273
/// This method sets ``AESCBCCryptor`` as the primary object for decryption and encryption. It also
264274
/// instantiates ``LegacyCryptor``under the hood with `withRandomIV`. This way, you can interact with historical
265275
/// messages or messages sent from older clients
266-
static func aesCbcCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptorModule {
267-
CryptorModule(default: AESCBCCryptor(key: key), cryptors: [LegacyCryptor(key: key, withRandomIV: withRandomIV)])
276+
static func aesCbcCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptoModule {
277+
CryptoModule(default: AESCBCCryptor(key: key), cryptors: [LegacyCryptor(key: key, withRandomIV: withRandomIV)])
268278
}
269279

270-
/// Returns legacy `CryptorModule` for encryption/decryption
280+
/// Returns legacy `CryptoModule` for encryption/decryption
271281
///
272282
/// - Parameters:
273283
/// - key: Key used for encryption/decryption
274284
/// - withRandomIV: A flag describing whether random initialization vector should be used
275285
/// - Warning: It's highly recommended to always use ``aesCbcCryptoModule(with:withRandomIV:)``
276-
static func legacyCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptorModule {
277-
CryptorModule(default: LegacyCryptor(key: key, withRandomIV: withRandomIV), cryptors: [AESCBCCryptor(key: key)])
286+
static func legacyCryptoModule(with key: String, withRandomIV: Bool = true) -> CryptoModule {
287+
CryptoModule(default: LegacyCryptor(key: key, withRandomIV: withRandomIV), cryptors: [AESCBCCryptor(key: key)])
278288
}
279289
}
280290

281-
extension CryptorModule: Equatable {
282-
public static func ==(lhs: CryptorModule, rhs: CryptorModule) -> Bool {
291+
extension CryptoModule: Equatable {
292+
public static func ==(lhs: CryptoModule, rhs: CryptoModule) -> Bool {
283293
lhs.cryptors.map { $0.id } == rhs.cryptors.map { $0.id }
284294
}
285295
}
286296

287-
extension CryptorModule: Hashable {
297+
extension CryptoModule: Hashable {
288298
public func hash(into hasher: inout Hasher) {
289299
hasher.combine(cryptors.map { $0.id })
290300
}
291301
}
292302

293-
extension CryptorModule: CustomStringConvertible {
303+
extension CryptoModule: CustomStringConvertible {
294304
public var description: String {
295305
"Default cryptor: \(defaultCryptor.id), others: \(cryptors.map { $0.id })"
296306
}
297307
}
298308

299-
internal extension CryptorModule {
309+
internal extension CryptoModule {
300310
func encrypt(string: String) -> Result<Base64EncodedString, PubNubError> {
301311
guard let data = string.data(using: .utf8) else {
302312
return .failure(PubNubError(

Sources/PubNub/Networking/HTTPFileTask.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public class HTTPFileDownloadTask: HTTPFileTask {
236236
/// The block that is called when the task completes
237237
public var completionBlock: ((Result<URL, Error>) -> Void)?
238238
/// The crypto object that will attempt to decrypt the file
239-
public var cryptorModule: CryptorModule?
239+
public var cryptoModule: CryptoModule?
240240

241241
/// The location where the temporary downloaded file should be copied
242242
public private(set) var destinationURL: URL
@@ -250,21 +250,21 @@ public class HTTPFileDownloadTask: HTTPFileTask {
250250
(urlSessionTask as? URLSessionDownloadTask)?.cancel(byProducingResumeData: byProducingResumeData)
251251
}
252252

253-
init(task: URLSessionDownloadTask, session identifier: String?, downloadTo url: URL, cryptorModule: CryptorModule?) {
253+
init(task: URLSessionDownloadTask, session identifier: String?, downloadTo url: URL, cryptoModule: CryptoModule?) {
254254
self.destinationURL = url
255-
self.cryptorModule = cryptorModule
255+
self.cryptoModule = cryptoModule
256256

257257
super.init(task: task, session: identifier)
258258
}
259259

260-
func decrypt(_ encryptedURL: URL, to outpuURL: URL, using cryptorModule: CryptorModule) throws {
260+
func decrypt(_ encryptedURL: URL, to outpuURL: URL, using cryptoModule: CryptoModule) throws {
261261
// If we were provided a Crypto object we should try and decrypt the file
262262

263263
guard let inputStream = InputStream(url: encryptedURL) else {
264264
throw PubNubError(.streamCouldNotBeInitialized, additional: [encryptedURL.absoluteString])
265265
}
266266

267-
cryptorModule.decrypt(
267+
cryptoModule.decrypt(
268268
stream: inputStream,
269269
contentLength: encryptedURL.sizeOf,
270270
to: outpuURL
@@ -324,15 +324,15 @@ public class HTTPFileDownloadTask: HTTPFileTask {
324324
// Update destination to be a unique file
325325
destinationURL = fileManager.makeUniqueFilename(destinationURL)
326326

327-
if let cryptorModule = cryptorModule {
327+
if let cryptoModule = cryptoModule {
328328
// Set the encrypted in case something goes wrong
329329
encryptedURL = url
330330

331331
guard let stream = InputStream(url: url) else {
332332
throw PubNubError(.streamCouldNotBeInitialized, additional: [url.absoluteString])
333333
}
334334

335-
cryptorModule.decrypt(
335+
cryptoModule.decrypt(
336336
stream: stream,
337337
contentLength: url.sizeOf,
338338
to: destinationURL

0 commit comments

Comments
 (0)