rn-linkrunner 2.5.2 → 2.6.0
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/LinkrunnerSDK.podspec +1 -1
- package/ios/Podfile +1 -1
- package/ios/Pods/LinkrunnerKit/LICENSE +21 -0
- package/ios/Pods/LinkrunnerKit/README.md +15 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/HmacSignatureGenerator.swift +95 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/Linkrunner.swift +1109 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/Models.swift +356 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/RequestSigningInterceptor.swift +110 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/SHA256.swift +12 -0
- package/ios/Pods/LinkrunnerKit/Sources/Linkrunner/SKAdNetworkService.swift +428 -0
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +440 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/shofiyabootwala.xcuserdatad/xcschemes/LinkrunnerKit.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/shofiyabootwala.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit-Info.plist +26 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit-dummy.m +5 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit-prefix.pch +12 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit.debug.xcconfig +17 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit.modulemap +6 -0
- package/ios/Pods/Target Support Files/LinkrunnerKit/LinkrunnerKit.release.xcconfig +17 -0
- package/package.json +1 -1
package/LinkrunnerSDK.podspec
CHANGED
package/ios/Podfile
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Linkrunner Private Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Linkrunner iOS SDK
|
|
2
|
+
|
|
3
|
+
A Swift package for integrating Linkrunner functionality into your iOS applications.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
For setup instructions, usage examples, and API reference, please visit:
|
|
8
|
+
|
|
9
|
+
[Linkrunner iOS SDK Documentation](https://docs.linkrunner.io/sdk/ios/installation)
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2025 Linkrunner Private Limited
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CommonCrypto
|
|
3
|
+
|
|
4
|
+
public class HmacSignatureGenerator {
|
|
5
|
+
// MARK: - Constants
|
|
6
|
+
private static let HMAC_ALGORITHM = kCCHmacAlgSHA256
|
|
7
|
+
|
|
8
|
+
// MARK: - Properties
|
|
9
|
+
private let secretKey: String
|
|
10
|
+
private let keyId: String
|
|
11
|
+
|
|
12
|
+
// MARK: - Initialization
|
|
13
|
+
public init(secretKey: String, keyId: String) {
|
|
14
|
+
self.secretKey = secretKey
|
|
15
|
+
self.keyId = keyId
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// MARK: - Models
|
|
19
|
+
public struct SignedRequest {
|
|
20
|
+
public let signature: String
|
|
21
|
+
public let timestamp: Int64
|
|
22
|
+
public let keyId: String
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// MARK: - Public Methods
|
|
26
|
+
public func signRequest(
|
|
27
|
+
payload: String?,
|
|
28
|
+
timestamp: Int64 = Int64(Date().timeIntervalSince1970 * 1000),
|
|
29
|
+
onCanonicalString: ((String) -> Void)? = nil
|
|
30
|
+
) -> SignedRequest {
|
|
31
|
+
// Calculate content hash if payload exists, otherwise use empty string
|
|
32
|
+
let contentHash: String
|
|
33
|
+
if let payload = payload, !payload.isEmpty {
|
|
34
|
+
contentHash = sha256Hash(payload)
|
|
35
|
+
} else {
|
|
36
|
+
contentHash = ""
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Build the canonical string with timestamp and content hash
|
|
40
|
+
let stringToSign = buildCanonicalString(timestamp: timestamp, contentHash: contentHash)
|
|
41
|
+
onCanonicalString?(stringToSign)
|
|
42
|
+
// Generate the signature
|
|
43
|
+
let signature = generateHmac(data: stringToSign)
|
|
44
|
+
|
|
45
|
+
return SignedRequest(signature: signature, timestamp: timestamp, keyId: keyId)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// MARK: - Private Methods
|
|
49
|
+
private func buildCanonicalString(timestamp: Int64, contentHash: String) -> String {
|
|
50
|
+
return "\(timestamp)\n\(contentHash)"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private func generateHmac(data: String) -> String {
|
|
54
|
+
guard let dataBytes = data.data(using: .utf8) else {
|
|
55
|
+
return ""
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Create a mutable pointer to hold the HMAC result
|
|
59
|
+
let digestLength = Int(CC_SHA256_DIGEST_LENGTH)
|
|
60
|
+
var hmacResult = [UInt8](repeating: 0, count: digestLength)
|
|
61
|
+
|
|
62
|
+
// Calculate HMAC using a more compatible approach
|
|
63
|
+
let keyData = Data(secretKey.utf8)
|
|
64
|
+
|
|
65
|
+
keyData.withUnsafeBytes { keyBytes in
|
|
66
|
+
dataBytes.withUnsafeBytes { dataBytes in
|
|
67
|
+
let keyPtr = keyBytes.baseAddress?.assumingMemoryBound(to: UInt8.self)
|
|
68
|
+
let dataPtr = dataBytes.baseAddress?.assumingMemoryBound(to: UInt8.self)
|
|
69
|
+
|
|
70
|
+
CCHmac(
|
|
71
|
+
CCHmacAlgorithm(kCCHmacAlgSHA256),
|
|
72
|
+
keyPtr, keyBytes.count,
|
|
73
|
+
dataPtr, dataBytes.count,
|
|
74
|
+
&hmacResult
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Convert to base64
|
|
80
|
+
let hmacData = Data(hmacResult)
|
|
81
|
+
return hmacData.base64EncodedString()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private func sha256Hash(_ data: String) -> String {
|
|
85
|
+
guard let dataBytes = data.data(using: .utf8) else { return "" }
|
|
86
|
+
|
|
87
|
+
var hashBytes = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
|
|
88
|
+
dataBytes.withUnsafeBytes { buffer in
|
|
89
|
+
_ = CC_SHA256(buffer.baseAddress, CC_LONG(buffer.count), &hashBytes)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let hashData = Data(hashBytes)
|
|
93
|
+
return hashData.base64EncodedString()
|
|
94
|
+
}
|
|
95
|
+
}
|