Skip to content

Commit

Permalink
Merge pull request #438 from Kommunicate-io/dev
Browse files Browse the repository at this point in the history
Release - 7.2.0
  • Loading branch information
AbhijeetRanjan308 authored Sep 11, 2024
2 parents d6ea131 + 975f86d commit f7f61fb
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 35 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# CHANGELOG

The changelog for [Kommunicate-iOS-SDK](https://github.com/Kommunicate-io/Kommunicate-iOS-SDK). Also see the [releases](https://github.com/Kommunicate-io/Kommunicate-iOS-SDK/releases) on Github.
## [7.2.0] 2024-09-11
- SSL Pining.
- Jail Break Detection.
- Resolved Rating Multiple Time Asking Issue.
- Rating Option will be avilable only after CSAT Enabling.
- Source Url UI added.
- Crash Fixes.
- Improved Form and Text Area UI.
- Delete Message Sync.

## [7.1.9] 2024-05-27
- Added Privacy Manifest File.
- Fixed color difference in Attachment Icon.
Expand Down
44 changes: 22 additions & 22 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- CwlCatchException (2.2.0):
- CwlCatchExceptionSupport (~> 2.2.0)
- CwlCatchExceptionSupport (2.2.0)
- CwlCatchExceptionSupport (2.2.1)
- CwlMachBadInstructionHandler (2.2.0)
- CwlPosixPreconditionTesting (2.2.0)
- CwlPreconditionTesting (2.2.1):
Expand All @@ -15,27 +15,27 @@ PODS:
- iOSSnapshotTestCase/SwiftSupport (8.0.0):
- iOSSnapshotTestCase/Core
- Kingfisher (7.6.2)
- Kommunicate (7.1.9):
- KommunicateChatUI-iOS-SDK (= 1.3.3)
- KommunicateChatUI-iOS-SDK (1.3.3):
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.3)
- KommunicateChatUI-iOS-SDK/Complete (1.3.3):
- Kommunicate (7.2.0):
- KommunicateChatUI-iOS-SDK (= 1.3.4)
- KommunicateChatUI-iOS-SDK (1.3.4):
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.4)
- KommunicateChatUI-iOS-SDK/Complete (1.3.4):
- iOSDropDown
- Kingfisher (~> 7.6.2)
- KommunicateChatUI-iOS-SDK/RichMessageKit
- KommunicateCore-iOS-SDK (= 1.2.1)
- KommunicateCore-iOS-SDK (= 1.2.2)
- SwipeCellKit (~> 2.7.1)
- ZendeskChatProvidersSDK (~> 3.0.0)
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.3)
- KommunicateCore-iOS-SDK (1.2.1)
- Nimble (13.3.0):
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.4)
- KommunicateCore-iOS-SDK (1.2.2)
- Nimble (13.4.0):
- CwlPreconditionTesting (~> 2.2.0)
- Nimble-Snapshots (9.7.0):
- Nimble-Snapshots/Core (= 9.7.0)
- Nimble-Snapshots/Core (9.7.0):
- Nimble-Snapshots (9.8.0):
- Nimble-Snapshots/Core (= 9.8.0)
- Nimble-Snapshots/Core (9.8.0):
- iOSSnapshotTestCase (~> 8.0)
- Nimble (~> 13.0)
- Quick (7.6.0)
- Quick (7.6.2)
- SwipeCellKit (2.7.1)
- ZendeskChatProvidersSDK (3.0.0)

Expand Down Expand Up @@ -70,22 +70,22 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
CwlCatchException: 51bf8319009a31104ea6f0568730d1ecc25b6454
CwlCatchExceptionSupport: 1345d6adb01a505933f2bc972dab60dcb9ce3e50
CwlCatchExceptionSupport: 54ccab8d8c78907b57f99717fb19d4cc3bce02dc
CwlMachBadInstructionHandler: ea1030428925d9bf340882522af30712fb4bf356
CwlPosixPreconditionTesting: a125dee731883f2582715f548c6b6c92c7fde145
CwlPreconditionTesting: ccfd08aca58d14e04062b2a3dd2fd52e09857453
iOSDropDown: ce9daa584eaa5567cafc1b633e3cc7eb6d9cea42
iOSSnapshotTestCase: a670511f9ee3829c2b9c23e6e68f315fd7b6790f
Kingfisher: 6c5449c6450c5239166510ba04afe374a98afc4f
Kommunicate: 7f3bd576c238ba492199de7ec3b119fa0cfa678d
KommunicateChatUI-iOS-SDK: c8cdd4c97266a21ce675144eb5b45bfa060cd2e6
KommunicateCore-iOS-SDK: 445c510bd901ca60e4aa8193beb46cfc7aeb2f27
Nimble: 3ac6c6b0b7e9835d1540b6507d8054b12a415536
Nimble-Snapshots: 7f2710c507469eb0fc4912f45d0f280e15f91966
Quick: a65742a544182cb9ecb231e1e71bcb87f4d12ce3
Kommunicate: 3b6277cc6db81a83f5f275ffa0d855de3a4e2a75
KommunicateChatUI-iOS-SDK: 5c56b67cf220b4f29d48660c1ecfc2e4c365a2a2
KommunicateCore-iOS-SDK: 98db0f992e382b8576ab9166b28cedb4661ece49
Nimble: c3d7c9848a0adae88a665ca52f8da23dd4d2cd94
Nimble-Snapshots: 240ea76ee8e52dfc1387b8d0d9bf1db3420cabbd
Quick: b8bec97cd4b9f21da0472d45580f763b801fc353
SwipeCellKit: 3972254a826da74609926daf59b08d6c72e619ea
ZendeskChatProvidersSDK: af93e02e2058875f92e6ad86e74ee51203b4079e

PODFILE CHECKSUM: 07a36a186f5848e9c0e96beedc0b1730ca2d51e8

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
4 changes: 2 additions & 2 deletions Kommunicate.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Kommunicate'
s.version = '7.1.9'
s.version = '7.2.0'
s.summary = 'Kommunicate iOS SDK for customer support.'
s.homepage = 'https://github.com/Kommunicate-io/Kommunicate-iOS-SDK'
s.license = { :type => 'BSD-3-Clause', :file => 'LICENSE' }
Expand All @@ -10,5 +10,5 @@ Pod::Spec.new do |s|
s.swift_version = '5.0'
s.source_files = 'Sources/Kommunicate/Classes/**/*.{swift}'
s.resources = 'Sources/Resources/**/*{lproj,storyboard,xib,xcassets,json,strings}'
s.dependency 'KommunicateChatUI-iOS-SDK' , '1.3.3'
s.dependency 'KommunicateChatUI-iOS-SDK' , '1.3.4'
end
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"repositoryURL": "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git",
"state": {
"branch": null,
"revision": "d2c51174087710f9f3d3550d90fcfeeac84041c8",
"version": "1.3.3"
"revision": "dc867d20cfd71161b39f0013f3eeed7258230245",
"version": "1.3.4"
}
},
{
"package": "KommunicateCore_iOS_SDK",
"repositoryURL": "https://github.com/Kommunicate-io/KommunicateCore-iOS-SDK.git",
"state": {
"branch": null,
"revision": "d8f3e1d62497b8df12d703bf2353bf7f795c5565",
"version": "1.2.1"
"revision": "72af41b1bfc512801bf746975f16738269e1e2c6",
"version": "1.2.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.3"),
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.4"),
],
targets: [
.target(
Expand Down
6 changes: 5 additions & 1 deletion Sources/Kommunicate/Classes/DataLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class DataLoader {

// set up the session
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let session = URLSession(
configuration: config,
delegate: KMURLSessionPinningDelegate(),
delegateQueue: nil
)

// make the request
let task = session.dataTask(with: urlRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public extension ALKConfiguration {
/// - Parameter tag: Language tag to set user's language
mutating func updateUserLanguage(tag: String) throws {
do {
try updateChatContext(with: [ChannelMetadataKeys.languageTag: tag])
try updateChatContext(with: [ChannelMetadataKeys.kmUserLocale: tag])
} catch {
throw error
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ extension KMConversationViewController: NavigationBarCallbacks {

extension KMConversationViewController {
func checkFeedbackAndShowRatingView() {
let isConversationRecentlyRated: Bool = {
guard let lastMessage = viewModel.messageModels.last, let metadata = lastMessage.metadata else { return false }
return lastMessage.messageType == .information && metadata["feedback"] != nil
}()
guard isClosedConversation else {
isClosedConversationViewHidden = true
hideRatingView()
Expand All @@ -710,7 +714,7 @@ extension KMConversationViewController {
self?.showRatingView()
return
}
guard !Kommunicate.defaultConfiguration.oneTimeRating else{
guard !Kommunicate.defaultConfiguration.oneTimeRating && !isConversationRecentlyRated else{
return
}
self?.showRatingView()
Expand Down
4 changes: 4 additions & 0 deletions Sources/Kommunicate/Classes/KMErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Foundation
public enum KMConversationError: LocalizedError {
/// Thrown when title is invalid.
case invalidTitle
/// Thrown when user device is rooted.
case deviceRooted
/// Thrown when user is not logged in.
case notLoggedIn
/// Thrown when Internet is not available.
Expand All @@ -23,6 +25,8 @@ public enum KMConversationError: LocalizedError {
switch self {
case .invalidTitle:
errorMessage = "Please pass a valid title."
case .deviceRooted:
errorMessage = "User device is Rooted."
case .notLoggedIn:
errorMessage = "User is not logged in."
case .internet:
Expand Down
68 changes: 68 additions & 0 deletions Sources/Kommunicate/Classes/KMURLSessionPinning.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// KMURLSessionPinning.swift
// Kommunicate
//
// Created by Abhijeet Ranjan on 03/09/24.
//

import Foundation
import KommunicateCore_iOS_SDK
import CommonCrypto

class KMURLSessionPinningDelegate: NSObject, URLSessionDelegate {

let rsa2048Asn1Header:[UInt8] = [
0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00
]

private func sha256(data : Data) -> String {
var keyWithHeader = Data(rsa2048Asn1Header)
keyWithHeader.append(data)
var hash = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
keyWithHeader.withUnsafeBytes {
_ = CC_SHA256($0.baseAddress, CC_LONG(keyWithHeader.count), &hash)
}
return Data(hash).base64EncodedString()
}

func fetchExpectedPublicKeyHashes(from bundle: Bundle) -> [String]? {
if let infoPlist = bundle.infoDictionary,
let keys = infoPlist["KMExpectedPublicKeyHashBase64"] as? [String] {
return keys
} else if let plistPath = bundle.path(forResource: "KommunicateCore-Info", ofType: "plist"),
let infoPlist = NSDictionary(contentsOfFile: plistPath) as? [String: Any],
let keys = infoPlist["KMExpectedPublicKeyHashBase64"] as? [String] {
return keys
}
return nil
}

func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Swift.Void) {

if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust),
let bundle = ALUtilityClass.getBundle(),
let kExpectedPublicKeyHashBase64 = fetchExpectedPublicKeyHashes(from: bundle) {
if let serverTrust = challenge.protectionSpace.serverTrust {
var secError: CFError?
let isTrustValid = SecTrustEvaluateWithError(serverTrust, &secError)
if (isTrustValid) {
if let serverCertificate = SecTrustGetCertificateAtIndex(serverTrust, 0) {
// Public key pinning
let serverPublicKey = SecCertificateCopyKey(serverCertificate)
let serverPublicKeyData:NSData = SecKeyCopyExternalRepresentation(serverPublicKey!, nil )!
let keyHash = sha256(data: serverPublicKeyData as Data)
if (kExpectedPublicKeyHashBase64.contains(keyHash)) {
// Success! This is our server
completionHandler(.useCredential, URLCredential(trust:serverTrust))
return
}
}
}
}
}
// Pinning failed
completionHandler(.cancelAuthenticationChallenge, nil)
}
}

Loading

0 comments on commit f7f61fb

Please sign in to comment.