securiti-consent-sdk 1.132.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/NitroSecuritiConsentSdk.podspec +37 -0
- package/README.md +45 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +146 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/securiticonsentsdk/HybridConsentSDK.kt +669 -0
- package/android/src/main/java/com/margelo/nitro/securiticonsentsdk/NitroSecuritiConsentSdkPackage.java +33 -0
- package/ios/Bridge.h +10 -0
- package/ios/HybridConsentSDK.swift +640 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroSecuritiConsentSdk+autolinking.cmake +78 -0
- package/nitrogen/generated/android/NitroSecuritiConsentSdk+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroSecuritiConsentSdkOnLoad.cpp +48 -0
- package/nitrogen/generated/android/NitroSecuritiConsentSdkOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JAppPermission.hpp +86 -0
- package/nitrogen/generated/android/c++/JBannerConfig.hpp +194 -0
- package/nitrogen/generated/android/c++/JCmpSDKOptions.hpp +94 -0
- package/nitrogen/generated/android/c++/JCustomColors.hpp +82 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +74 -0
- package/nitrogen/generated/android/c++/JHybridConsentSDKSpec.cpp +277 -0
- package/nitrogen/generated/android/c++/JHybridConsentSDKSpec.hpp +78 -0
- package/nitrogen/generated/android/c++/JPermissionConsent.hpp +61 -0
- package/nitrogen/generated/android/c++/JPostConsentsRequest.hpp +137 -0
- package/nitrogen/generated/android/c++/JPurpose.hpp +118 -0
- package/nitrogen/generated/android/c++/JPurposeConsent.hpp +65 -0
- package/nitrogen/generated/android/c++/JSDK.hpp +104 -0
- package/nitrogen/generated/android/c++/JSettingsPrompt.hpp +88 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/AppPermission.kt +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/BannerConfig.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/CmpSDKOptions.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/CustomColors.kt +33 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/HybridConsentSDKSpec.kt +121 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/NitroSecuritiConsentSdkOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/PermissionConsent.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/PostConsentsRequest.kt +37 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/Purpose.kt +37 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/PurposeConsent.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/SDK.kt +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/securiticonsentsdk/SettingsPrompt.kt +30 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdk+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdk-Swift-Cxx-Bridge.cpp +96 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdk-Swift-Cxx-Bridge.hpp +604 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdk-Swift-Cxx-Umbrella.hpp +78 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdkAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroSecuritiConsentSdkAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridConsentSDKSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridConsentSDKSpecSwift.hpp +223 -0
- package/nitrogen/generated/ios/swift/AppPermission.swift +267 -0
- package/nitrogen/generated/ios/swift/BannerConfig.swift +918 -0
- package/nitrogen/generated/ios/swift/CmpSDKOptions.swift +217 -0
- package/nitrogen/generated/ios/swift/CustomColors.swift +256 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_BannerConfig_.swift +52 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_SettingsPrompt_.swift +52 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_AppPermission_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_Purpose_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_SDK_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridConsentSDKSpec.swift +64 -0
- package/nitrogen/generated/ios/swift/HybridConsentSDKSpec_cxx.swift +398 -0
- package/nitrogen/generated/ios/swift/PermissionConsent.swift +57 -0
- package/nitrogen/generated/ios/swift/PostConsentsRequest.swift +216 -0
- package/nitrogen/generated/ios/swift/Purpose.swift +354 -0
- package/nitrogen/generated/ios/swift/PurposeConsent.swift +68 -0
- package/nitrogen/generated/ios/swift/SDK.swift +285 -0
- package/nitrogen/generated/ios/swift/SettingsPrompt.swift +181 -0
- package/nitrogen/generated/shared/c++/AppPermission.hpp +102 -0
- package/nitrogen/generated/shared/c++/BannerConfig.hpp +197 -0
- package/nitrogen/generated/shared/c++/CmpSDKOptions.hpp +110 -0
- package/nitrogen/generated/shared/c++/CustomColors.hpp +98 -0
- package/nitrogen/generated/shared/c++/HybridConsentSDKSpec.cpp +37 -0
- package/nitrogen/generated/shared/c++/HybridConsentSDKSpec.hpp +102 -0
- package/nitrogen/generated/shared/c++/PermissionConsent.hpp +77 -0
- package/nitrogen/generated/shared/c++/PostConsentsRequest.hpp +120 -0
- package/nitrogen/generated/shared/c++/Purpose.hpp +117 -0
- package/nitrogen/generated/shared/c++/PurposeConsent.hpp +81 -0
- package/nitrogen/generated/shared/c++/SDK.hpp +103 -0
- package/nitrogen/generated/shared/c++/SettingsPrompt.hpp +87 -0
- package/package.json +107 -0
- package/react-native.config.js +16 -0
- package/src/ConsentSDK.nitro.ts +232 -0
- package/src/index.ts +133 -0
package/ios/Bridge.h
ADDED
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
import ConsentUI
|
|
2
|
+
import os
|
|
3
|
+
import NitroModules
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of the HybridConsentSDK iOS for React Native.
|
|
7
|
+
*/
|
|
8
|
+
public class HybridConsentSDK : HybridConsentSDKSpec {
|
|
9
|
+
|
|
10
|
+
private var sdkOptions: CmpSDKOptions?
|
|
11
|
+
|
|
12
|
+
public override init() {
|
|
13
|
+
print("*** HybridConsentSDK - initializer called ***")
|
|
14
|
+
os_log("*** HybridConsentSDK - initializer called in os_log ***")
|
|
15
|
+
super.init()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public func initialize(options: CmpSDKOptions) throws {
|
|
19
|
+
print("*** initialize method called with options: \(options) ***")
|
|
20
|
+
os_log("*** initialize method called in os_log ***")
|
|
21
|
+
|
|
22
|
+
// Store options for later reference
|
|
23
|
+
self.sdkOptions = options
|
|
24
|
+
|
|
25
|
+
// Determine log level based on options
|
|
26
|
+
let logLevel: ConsentUI.LogLevel
|
|
27
|
+
switch options.loggerLevel.lowercased() {
|
|
28
|
+
case "debug":
|
|
29
|
+
logLevel = .debug
|
|
30
|
+
case "info":
|
|
31
|
+
logLevel = .info
|
|
32
|
+
case "warning", "warn":
|
|
33
|
+
logLevel = .warning
|
|
34
|
+
case "error":
|
|
35
|
+
logLevel = .error
|
|
36
|
+
default:
|
|
37
|
+
logLevel = .debug
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Set up SDK with options
|
|
41
|
+
ConsentSDK.shared.setupSDK(options: ConsentUI.ConsentSDKOptions(
|
|
42
|
+
appUrl: options.appURL,
|
|
43
|
+
cdnUrl: options.cdnURL,
|
|
44
|
+
tenantId: options.tenantID,
|
|
45
|
+
appId: options.appID,
|
|
46
|
+
testingMode: options.testingMode,
|
|
47
|
+
logLevel: logLevel,
|
|
48
|
+
consentsCheckInterval: Int(options.consentsCheckInterval),
|
|
49
|
+
languageCode: options.languageCode,
|
|
50
|
+
locationCode: options.locationCode
|
|
51
|
+
))
|
|
52
|
+
|
|
53
|
+
// Register for ready status
|
|
54
|
+
ConsentSDK.shared.isReady { state in
|
|
55
|
+
print("*** SDK Status is \(state) ***")
|
|
56
|
+
os_log("*** SDK Status is %@ ***", String(describing: state))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public func isSdkReady() throws -> Bool {
|
|
61
|
+
print("*** isSdkReady method called ***")
|
|
62
|
+
os_log("*** isSdkReady method called in os_log ***")
|
|
63
|
+
return ConsentSDK.shared.getStatus() == .available
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public func presentPreferenceCenter() throws {
|
|
67
|
+
print("*** presentPreferenceCenter method called ***")
|
|
68
|
+
os_log("*** presentPreferenceCenter method called in os_log ***")
|
|
69
|
+
|
|
70
|
+
// Check if SDK is ready before presenting
|
|
71
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
72
|
+
let error = NSError(domain: "HybridConsentSDK", code: 1,
|
|
73
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"])
|
|
74
|
+
print("*** Error: SDK is not ready ***")
|
|
75
|
+
os_log("*** Error: SDK is not ready ***")
|
|
76
|
+
throw error
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ConsentSDK.shared.presentPreferenceCenter()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public func presentConsentBanner() throws {
|
|
83
|
+
print("*** presentConsentBanner method called ***")
|
|
84
|
+
os_log("*** presentConsentBanner method called in os_log ***")
|
|
85
|
+
|
|
86
|
+
// Check if SDK is ready before presenting
|
|
87
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
88
|
+
let error = NSError(domain: "HybridConsentSDK", code: 1,
|
|
89
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"])
|
|
90
|
+
print("*** Error: SDK is not ready ***")
|
|
91
|
+
os_log("*** Error: SDK is not ready ***")
|
|
92
|
+
throw error
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
ConsentSDK.shared.presentConsentBanner()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public func isReady(callback: @escaping (Bool) -> Void) throws {
|
|
99
|
+
print("*** isReady method called ***")
|
|
100
|
+
os_log("*** isReady method called in os_log ***")
|
|
101
|
+
|
|
102
|
+
ConsentSDK.shared.isReady { state in
|
|
103
|
+
callback(state == .available)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public func resetConsents() throws {
|
|
108
|
+
print("*** resetConsents method called ***")
|
|
109
|
+
os_log("*** resetConsents method called in os_log ***")
|
|
110
|
+
|
|
111
|
+
// Check if SDK is ready
|
|
112
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
113
|
+
let error = NSError(domain: "HybridConsentSDK", code: 1,
|
|
114
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"])
|
|
115
|
+
print("*** Error: SDK is not ready ***")
|
|
116
|
+
os_log("*** Error: SDK is not ready ***")
|
|
117
|
+
throw error
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ConsentSDK.shared.removeConsents()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// MARK: - Consent Management Methods
|
|
124
|
+
|
|
125
|
+
public func getPurposes() throws -> Promise<[Purpose]> {
|
|
126
|
+
print("*** getPurposes method called ***")
|
|
127
|
+
os_log("*** getPurposes method called in os_log ***")
|
|
128
|
+
|
|
129
|
+
return Promise.async {
|
|
130
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
131
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
132
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
133
|
+
return []
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Retrieve purposes from the SDK
|
|
137
|
+
let nativePurposes = await ConsentSDK.shared.getPurposeConsents()
|
|
138
|
+
|
|
139
|
+
// Convert native purposes to our Purpose model
|
|
140
|
+
var purposes: [Purpose] = []
|
|
141
|
+
|
|
142
|
+
for nativePurpose in nativePurposes {
|
|
143
|
+
var purpose = Purpose()
|
|
144
|
+
|
|
145
|
+
// Map properties from native Purpose to our Purpose model
|
|
146
|
+
purpose.purposeId = Double(nativePurpose.purposeId ?? -1)
|
|
147
|
+
purpose.purposeName = self.getString(nativePurpose.purposeName)
|
|
148
|
+
purpose.purposeDescription = self.getString(nativePurpose.purposeDescription)
|
|
149
|
+
purpose.disableOptOut = nativePurpose.disableOptOut
|
|
150
|
+
purpose.optOutText = self.getString(nativePurpose.optOutText)
|
|
151
|
+
purpose.hideDetails = nativePurpose.hideDetails
|
|
152
|
+
purpose.isATTMapped = nativePurpose.isATTMapped
|
|
153
|
+
purpose.attDescription = self.getString(nativePurpose.attDescription)
|
|
154
|
+
|
|
155
|
+
// Convert consent status
|
|
156
|
+
switch nativePurpose.consentStatus {
|
|
157
|
+
case .granted:
|
|
158
|
+
purpose.consentStatus = "granted"
|
|
159
|
+
case .declined:
|
|
160
|
+
purpose.consentStatus = "declined"
|
|
161
|
+
case .notDetermined:
|
|
162
|
+
purpose.consentStatus = "not_determined"
|
|
163
|
+
case .withDrawn:
|
|
164
|
+
purpose.consentStatus = "withdrawn"
|
|
165
|
+
@unknown default:
|
|
166
|
+
purpose.consentStatus = "not_determined"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Convert SDK array
|
|
170
|
+
if let nativeSDKs = nativePurpose.sdks {
|
|
171
|
+
var sdks: [SDK] = []
|
|
172
|
+
|
|
173
|
+
for nativeSDK in nativeSDKs {
|
|
174
|
+
var sdk = SDK()
|
|
175
|
+
|
|
176
|
+
// Map SDK properties
|
|
177
|
+
sdk.sdkId = Double(nativeSDK.sdkId ?? -1)
|
|
178
|
+
sdk.namespaceId = nativeSDK.namespaceId
|
|
179
|
+
sdk.sdkName = self.getString(nativeSDK.sdkName)
|
|
180
|
+
sdk.sdkDescription = self.getString(nativeSDK.sdkDescription)
|
|
181
|
+
sdk.vendor = nativeSDK.vendor
|
|
182
|
+
sdk.logoBase64 = nativeSDK.logoBase64
|
|
183
|
+
sdk.website = nativeSDK.website
|
|
184
|
+
sdk.matchedBy = nativeSDK.matchedBy
|
|
185
|
+
sdk.collectingData = nativeSDK.collectingData
|
|
186
|
+
|
|
187
|
+
sdks.append(sdk)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
purpose.sdks = sdks
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
purposes.append(purpose)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return purposes
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public func getConsentByPurposeId(purposeId: Double) throws -> NitroModules.Promise<String> {
|
|
201
|
+
print("*** getConsentByPurposeId method called with purposeId: \(purposeId) ***")
|
|
202
|
+
os_log("*** getConsentByPurposeId method called in os_log ***")
|
|
203
|
+
|
|
204
|
+
return Promise.async {
|
|
205
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
206
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
207
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
208
|
+
return "unknown"
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Convert from SecuritiMobileCmp ConsentStatus to string
|
|
212
|
+
let consentStatus = ConsentSDK.shared.getConsent(purposeId: Int(purposeId))
|
|
213
|
+
return switch consentStatus {
|
|
214
|
+
case .granted:
|
|
215
|
+
"granted"
|
|
216
|
+
case .declined:
|
|
217
|
+
"declined"
|
|
218
|
+
case .notDetermined:
|
|
219
|
+
"not_determined"
|
|
220
|
+
case .withDrawn:
|
|
221
|
+
"withdrawn"
|
|
222
|
+
@unknown default:
|
|
223
|
+
"not_determined"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public func getPermissions() throws -> Promise<[AppPermission]> {
|
|
229
|
+
print("*** getPermissions method called ***")
|
|
230
|
+
os_log("*** getPermissions method called in os_log ***")
|
|
231
|
+
|
|
232
|
+
return Promise.async {
|
|
233
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
234
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
235
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
236
|
+
return []
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Retrieve permissions from the SDK
|
|
240
|
+
let permissions = await ConsentSDK.shared.getPermissionConsents()
|
|
241
|
+
|
|
242
|
+
// Convert native permissions to our AppPermission model
|
|
243
|
+
var appPermissions: [AppPermission] = []
|
|
244
|
+
|
|
245
|
+
for permission in permissions {
|
|
246
|
+
var appPermission = AppPermission()
|
|
247
|
+
|
|
248
|
+
// Map properties from native Permission to our AppPermission
|
|
249
|
+
appPermission.id = Double(permission.id ?? -1)
|
|
250
|
+
appPermission.name = permission.name
|
|
251
|
+
appPermission.permissionId = permission.permissionId?.rawValue
|
|
252
|
+
appPermission.description = self.getString(permission.description)
|
|
253
|
+
appPermission.group = permission.group
|
|
254
|
+
appPermission.groupId = Double(permission.groupId ?? -1)
|
|
255
|
+
appPermission.nameMap = self.getString(permission.nameMap)
|
|
256
|
+
appPermission.isSettingsPromptEnabled = permission.isSettingsPromptEnabled
|
|
257
|
+
|
|
258
|
+
// Convert consent status
|
|
259
|
+
switch permission.consentStatus {
|
|
260
|
+
case .granted:
|
|
261
|
+
appPermission.consentStatus = "granted"
|
|
262
|
+
case .declined:
|
|
263
|
+
appPermission.consentStatus = "declined"
|
|
264
|
+
case .notDetermined:
|
|
265
|
+
appPermission.consentStatus = "not_determined"
|
|
266
|
+
case .withDrawn:
|
|
267
|
+
appPermission.consentStatus = "withdrawn"
|
|
268
|
+
@unknown default:
|
|
269
|
+
appPermission.consentStatus = "not_determined"
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
appPermissions.append(appPermission)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return appPermissions
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public func getSdksInPurpose(purposeId: Double) throws -> NitroModules.Promise<[SDK]> {
|
|
280
|
+
print("*** getSdksInPurpose method called with purposeId: \(purposeId) ***")
|
|
281
|
+
os_log("*** getSdksInPurpose method called in os_log ***")
|
|
282
|
+
|
|
283
|
+
return Promise.async {
|
|
284
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
285
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
286
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
287
|
+
return []
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Retrieve SDKs from the purpose
|
|
291
|
+
let nativeSDKs = await ConsentSDK.shared.getPurposeConsents().first(where: { $0.purposeId == Int(purposeId) })?.sdks ?? []
|
|
292
|
+
|
|
293
|
+
// Convert native SDKs to our SDK model
|
|
294
|
+
var sdks: [SDK] = []
|
|
295
|
+
|
|
296
|
+
for nativeSDK in nativeSDKs {
|
|
297
|
+
var sdk = SDK()
|
|
298
|
+
|
|
299
|
+
// Map SDK properties
|
|
300
|
+
sdk.sdkId = Double(nativeSDK.sdkId ?? -1)
|
|
301
|
+
sdk.namespaceId = nativeSDK.namespaceId
|
|
302
|
+
sdk.sdkName = self.getString(nativeSDK.sdkName)
|
|
303
|
+
sdk.sdkDescription = self.getString(nativeSDK.sdkDescription)
|
|
304
|
+
sdk.vendor = nativeSDK.vendor
|
|
305
|
+
sdk.logoBase64 = nativeSDK.logoBase64
|
|
306
|
+
sdk.website = nativeSDK.website
|
|
307
|
+
sdk.matchedBy = nativeSDK.matchedBy
|
|
308
|
+
sdk.collectingData = nativeSDK.collectingData
|
|
309
|
+
|
|
310
|
+
sdks.append(sdk)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return sdks
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public func getBannerConfig() throws -> Promise<BannerConfig?> {
|
|
318
|
+
print("*** getBannerConfig method called ***")
|
|
319
|
+
os_log("*** getBannerConfig method called in os_log ***")
|
|
320
|
+
|
|
321
|
+
return Promise.async {
|
|
322
|
+
|
|
323
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
324
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
325
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
326
|
+
return BannerConfig()
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Otherwise try to get config from the SDK
|
|
330
|
+
if let nativeBannerConfig = await ConsentSDK.shared.getBannerConfig() {
|
|
331
|
+
var bannerConfig = BannerConfig()
|
|
332
|
+
|
|
333
|
+
// Map properties from native BannerConfig to our model
|
|
334
|
+
bannerConfig.hideCloseButton = nativeBannerConfig.hideCloseButton
|
|
335
|
+
bannerConfig.hideAcceptButton = nativeBannerConfig.hideAcceptButton
|
|
336
|
+
bannerConfig.embedDSRPortalLink = nativeBannerConfig.embedDSRPortalLink
|
|
337
|
+
bannerConfig.recordConsentUponAppStart = nativeBannerConfig.recordConsentUponAppStart
|
|
338
|
+
bannerConfig.hideToggleForEssentialCategories = nativeBannerConfig.hideToggleForEssentialCategories
|
|
339
|
+
bannerConfig.name = nativeBannerConfig.name
|
|
340
|
+
bannerConfig.dsrPortalLink = nativeBannerConfig.dsrPortalLink
|
|
341
|
+
bannerConfig.complianceType = nativeBannerConfig.complianceType?.rawValue ?? "notice-only"
|
|
342
|
+
bannerConfig.bannerReappearanceTime = nativeBannerConfig.bannerReappearanceTime
|
|
343
|
+
bannerConfig.privacyNoticeLink = nativeBannerConfig.privacyNoticeLink
|
|
344
|
+
bannerConfig.accept = self.getString(nativeBannerConfig.accept)
|
|
345
|
+
bannerConfig.reject = self.getString(nativeBannerConfig.reject)
|
|
346
|
+
bannerConfig.bannerText = self.getString(nativeBannerConfig.bannerText)
|
|
347
|
+
bannerConfig.bannerHeading = self.getString(nativeBannerConfig.bannerHeading)
|
|
348
|
+
bannerConfig.sdkTabHeading = self.getString(nativeBannerConfig.sdkTabHeading)
|
|
349
|
+
bannerConfig.privacyNoticeText = self.getString(nativeBannerConfig.privacyNoticeText)
|
|
350
|
+
bannerConfig.preferenceCenterLink = self.getString(nativeBannerConfig.preferenceCenterLink)
|
|
351
|
+
bannerConfig.permissionsTabHeading = self.getString(nativeBannerConfig.permissionsTabHeading)
|
|
352
|
+
bannerConfig.permissionsTabGuidance = self.getString(nativeBannerConfig.permissionsTabGuidance)
|
|
353
|
+
bannerConfig.preferenceCenterHeading = self.getString(nativeBannerConfig.preferenceCenterHeading)
|
|
354
|
+
bannerConfig.preferenceCenterGuidance = self.getString(nativeBannerConfig.preferenceCenterGuidance)
|
|
355
|
+
bannerConfig.permissionsTabDescription = self.getString(nativeBannerConfig.permissionsTabDescription)
|
|
356
|
+
bannerConfig.preferenceCenterDescription = self.getString(nativeBannerConfig.preferenceCenterDescription)
|
|
357
|
+
bannerConfig.showPoweredBySecuritiLogo = nativeBannerConfig.showPoweredBySecuritiLogo
|
|
358
|
+
bannerConfig.showDescriptionTextWithPrefCenterToggle = nativeBannerConfig.showDescriptionTextWithPrefCenterToggle
|
|
359
|
+
bannerConfig.paletteTheme = Double(nativeBannerConfig.paletteTheme ?? 1)
|
|
360
|
+
bannerConfig.bannerPosition = nativeBannerConfig.bannerPosition?.rawValue
|
|
361
|
+
bannerConfig.buttonShape = nativeBannerConfig.buttonShape?.rawValue
|
|
362
|
+
bannerConfig.companyLogo = nativeBannerConfig.companyLogo
|
|
363
|
+
// Convert nested dictionary structure to a flattened Map
|
|
364
|
+
if let nestedTranslations = nativeBannerConfig.translations {
|
|
365
|
+
var flattenedTranslations: [String: String] = [:]
|
|
366
|
+
|
|
367
|
+
// For each parent key (e.g., "Go back")
|
|
368
|
+
for (parentKey, innerDict) in nestedTranslations {
|
|
369
|
+
// Get the inner dictionary and extract its values directly
|
|
370
|
+
flattenedTranslations[parentKey] = self.getString(innerDict)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
bannerConfig.translations = flattenedTranslations
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Map custom colors if available
|
|
377
|
+
if let nativeColors = nativeBannerConfig.customPaletteTheme {
|
|
378
|
+
var customColors = CustomColors()
|
|
379
|
+
customColors.buttonBackground = nativeColors.buttonBackground
|
|
380
|
+
customColors.buttonText = nativeColors.buttonText
|
|
381
|
+
customColors.buttonBorder = nativeColors.buttonBorder
|
|
382
|
+
customColors.bannerBackground = nativeColors.bannerBackground
|
|
383
|
+
customColors.bannerText = nativeColors.bannerText
|
|
384
|
+
customColors.bannerLinks = nativeColors.bannerLinks
|
|
385
|
+
customColors.preferenceCenterFooterBackground = nativeColors.preferenceCenterFooterBackground
|
|
386
|
+
customColors.preferenceCenterFooterSelector = nativeColors.preferenceCenterFooterSelector
|
|
387
|
+
|
|
388
|
+
bannerConfig.customPaletteTheme = customColors
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return bannerConfig
|
|
392
|
+
} else {
|
|
393
|
+
return nil
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public func options() throws -> CmpSDKOptions? {
|
|
399
|
+
print("*** options method called ***")
|
|
400
|
+
os_log("*** options method called in os_log ***")
|
|
401
|
+
|
|
402
|
+
// Just return the stored options from the initialize call
|
|
403
|
+
return self.sdkOptions
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
public func getSettingsPrompt() throws -> Promise<SettingsPrompt?> {
|
|
407
|
+
print("*** getSettingsPrompt method called ***")
|
|
408
|
+
os_log("*** getSettingsPrompt method called in os_log ***")
|
|
409
|
+
|
|
410
|
+
return Promise.async {
|
|
411
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
412
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
413
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
414
|
+
return SettingsPrompt()
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Get settings prompt configuration
|
|
418
|
+
if let nativeSettingsPrompt = await ConsentSDK.shared.getSettingsPrompt() {
|
|
419
|
+
var settingsPrompt = SettingsPrompt()
|
|
420
|
+
|
|
421
|
+
var settingPromptPermissions: [String] = []
|
|
422
|
+
|
|
423
|
+
nativeSettingsPrompt.permissions?.keys.forEach {
|
|
424
|
+
if(nativeSettingsPrompt.permissions?[$0] == true) {
|
|
425
|
+
settingPromptPermissions.append($0)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Map properties from native SettingsPrompt to our model
|
|
430
|
+
settingsPrompt.promptHeading = self.getString(nativeSettingsPrompt.promptHeading)
|
|
431
|
+
settingsPrompt.promptMessage = self.getString(nativeSettingsPrompt.promptMessage)
|
|
432
|
+
settingsPrompt.settingsButtonText = self.getString(nativeSettingsPrompt.settingsButtonText)
|
|
433
|
+
settingsPrompt.notNowButtonText = self.getString(nativeSettingsPrompt.notNowButtonText)
|
|
434
|
+
settingsPrompt.permissions = settingPromptPermissions
|
|
435
|
+
|
|
436
|
+
return settingsPrompt
|
|
437
|
+
} else {
|
|
438
|
+
return SettingsPrompt()
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
public func uploadConsents(request: PostConsentsRequest) throws -> Promise<Bool> {
|
|
444
|
+
print("*** uploadConsents method called ***")
|
|
445
|
+
os_log("*** uploadConsents method called in os_log ***")
|
|
446
|
+
|
|
447
|
+
return Promise.async {
|
|
448
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
449
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
450
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
451
|
+
return false
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Create native purpose consents array
|
|
455
|
+
var nativePurposeConsents: [ConsentUI.PurposeConsent] = []
|
|
456
|
+
for purposeConsent in request.purposeConsents {
|
|
457
|
+
let consentStatus = self.convertStringToConsentStatus(purposeConsent.consentStatus)
|
|
458
|
+
let nativePurposeConsent = ConsentUI.PurposeConsent(
|
|
459
|
+
purposeID: Int(purposeConsent.purposeID),
|
|
460
|
+
consentStatus: consentStatus,
|
|
461
|
+
timestamp: Int64(purposeConsent.timestamp),
|
|
462
|
+
isEssential: purposeConsent.isEssential
|
|
463
|
+
)
|
|
464
|
+
nativePurposeConsents.append(nativePurposeConsent)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Create native permission consents array
|
|
468
|
+
var nativePermissionConsents: [ConsentUI.PermissionConsent] = []
|
|
469
|
+
for permissionConsent in request.permissions {
|
|
470
|
+
let consentStatus = self.convertStringToConsentStatus(permissionConsent.consentStatus)
|
|
471
|
+
let nativePermissionConsent = ConsentUI.PermissionConsent(
|
|
472
|
+
permission: (ConsentUI.PrivaciKey(rawValue: permissionConsent.permission) ?? .none)!,
|
|
473
|
+
consentStatus: consentStatus,
|
|
474
|
+
timestamp: Int64(permissionConsent.timestamp)
|
|
475
|
+
)
|
|
476
|
+
nativePermissionConsents.append(nativePermissionConsent)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Create the request object for native SDK
|
|
480
|
+
let nativeRequest = ConsentUI.PostConsentsRequest(
|
|
481
|
+
uuid: request.uuid,
|
|
482
|
+
appUUID: request.appUUID,
|
|
483
|
+
device: request.device,
|
|
484
|
+
implicitConsent: request.implicitConsent,
|
|
485
|
+
version: Int(request.version),
|
|
486
|
+
purposeConsents: nativePurposeConsents,
|
|
487
|
+
permissions: nativePermissionConsents,
|
|
488
|
+
testingMode: request.isTestMode,
|
|
489
|
+
adId: request.adId,
|
|
490
|
+
bannerInfo: request.bannerInfo
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
// Upload consents
|
|
494
|
+
await ConsentSDK.shared.uploadConsents(url: self.sdkOptions?.appURL ?? "", request: nativeRequest)
|
|
495
|
+
return true
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
public func getConsentByPermissionId(permissionId: String) throws -> Promise<String> {
|
|
500
|
+
print("*** getConsentByPermissionId method called with permissionId: \(permissionId) ***")
|
|
501
|
+
os_log("*** getConsentByPermissionId method called in os_log ***")
|
|
502
|
+
|
|
503
|
+
return Promise.async {
|
|
504
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
505
|
+
debugPrint(NSError(domain: "HybridConsentSDK", code: 1,
|
|
506
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"]))
|
|
507
|
+
return "unknown"
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
let nativeId : PrivaciKey = PrivaciKey(rawValue: permissionId) ?? .custom("unknown")
|
|
511
|
+
|
|
512
|
+
// Convert from SecuritiMobileCmp ConsentStatus to string
|
|
513
|
+
let consentStatus = ConsentSDK.shared.getConsent(privaciKey: nativeId)
|
|
514
|
+
return switch consentStatus {
|
|
515
|
+
case .granted:
|
|
516
|
+
"granted"
|
|
517
|
+
case .declined:
|
|
518
|
+
"declined"
|
|
519
|
+
case .notDetermined:
|
|
520
|
+
"not_determined"
|
|
521
|
+
case .withDrawn:
|
|
522
|
+
"withdrawn"
|
|
523
|
+
@unknown default:
|
|
524
|
+
"not_determined"
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
public func setPurposeConsent(purpose: Purpose, consent: String) throws -> Bool {
|
|
530
|
+
print("*** setPurposeConsent method called with consent: \(consent) ***")
|
|
531
|
+
os_log("*** setPurposeConsent method called in os_log ***")
|
|
532
|
+
|
|
533
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
534
|
+
let error = NSError(domain: "HybridConsentSDK", code: 1,
|
|
535
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"])
|
|
536
|
+
print("*** Error: SDK is not ready ***")
|
|
537
|
+
os_log("*** Error: SDK is not ready ***")
|
|
538
|
+
throw error
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Convert string consent status to native ConsentStatus
|
|
542
|
+
let consentStatus = self.convertStringToConsentStatus(consent)
|
|
543
|
+
|
|
544
|
+
// Convert to native purpose
|
|
545
|
+
let nativePurpose = self.convertToPurpose(purpose)
|
|
546
|
+
|
|
547
|
+
// Set purpose consent
|
|
548
|
+
return ConsentSDK.shared.setConsent(purpose: nativePurpose, consent: consentStatus)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
public func setPermissionConsent(permission: AppPermission, consent: String) throws -> Bool {
|
|
552
|
+
print("*** setPermissionConsent method called with consent: \(consent) ***")
|
|
553
|
+
os_log("*** setPermissionConsent method called in os_log ***")
|
|
554
|
+
|
|
555
|
+
if ConsentSDK.shared.getStatus() != .available {
|
|
556
|
+
let error = NSError(domain: "HybridConsentSDK", code: 1,
|
|
557
|
+
userInfo: [NSLocalizedDescriptionKey: "SDK is not ready"])
|
|
558
|
+
print("*** Error: SDK is not ready ***")
|
|
559
|
+
os_log("*** Error: SDK is not ready ***")
|
|
560
|
+
throw error
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Convert string consent status to native ConsentStatus
|
|
564
|
+
let consentStatus = self.convertStringToConsentStatus(consent)
|
|
565
|
+
|
|
566
|
+
// Convert to native permission
|
|
567
|
+
let nativePermission = self.convertToAppPermission(permission)
|
|
568
|
+
|
|
569
|
+
// Set permission consent
|
|
570
|
+
return ConsentSDK.shared.setConsent(permission: nativePermission, consent: consentStatus)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// MARK: - Helper Methods
|
|
574
|
+
|
|
575
|
+
private func convertStringToConsentStatus(_ status: String) -> ConsentUI.ConsentStatus {
|
|
576
|
+
switch status.lowercased() {
|
|
577
|
+
case "granted":
|
|
578
|
+
return .granted
|
|
579
|
+
case "declined":
|
|
580
|
+
return .declined
|
|
581
|
+
case "not_determined":
|
|
582
|
+
return .notDetermined
|
|
583
|
+
case "withdrawn":
|
|
584
|
+
return .withDrawn
|
|
585
|
+
default:
|
|
586
|
+
return .notDetermined
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
private func convertToPurpose(_ purpose: Purpose) -> ConsentUI.Purpose {
|
|
591
|
+
// Create JSON representation of purpose
|
|
592
|
+
let encoder = JSONEncoder()
|
|
593
|
+
encoder.keyEncodingStrategy = .convertToSnakeCase
|
|
594
|
+
|
|
595
|
+
// Purpose data to encode
|
|
596
|
+
let purposeData: [String: Any] = [
|
|
597
|
+
"purpose_id": purpose.purposeId as Any,
|
|
598
|
+
"purpose_name": purpose.purposeName as Any,
|
|
599
|
+
"purpose_description": purpose.purposeDescription as Any,
|
|
600
|
+
"sdks": [], // Empty array as we handle SDKs separately
|
|
601
|
+
"disable_opt_out": purpose.disableOptOut as Any,
|
|
602
|
+
"opt_out_text": purpose.optOutText as Any,
|
|
603
|
+
"hide_details": purpose.hideDetails as Any
|
|
604
|
+
]
|
|
605
|
+
|
|
606
|
+
// Convert to JSON data
|
|
607
|
+
let jsonData = try! JSONSerialization.data(withJSONObject: purposeData)
|
|
608
|
+
|
|
609
|
+
// Decode into ConsentUI.Purpose
|
|
610
|
+
var nativePurpose = try! JSONDecoder().decode(ConsentUI.Purpose.self, from: jsonData)
|
|
611
|
+
|
|
612
|
+
return nativePurpose
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
private func convertToAppPermission(_ permission: AppPermission) -> ConsentUI.AppPermission {
|
|
616
|
+
// Create JSON representation of permission
|
|
617
|
+
let permissionData: [String: Any] = [
|
|
618
|
+
"id": permission.id as Any,
|
|
619
|
+
"name": permission.name as Any,
|
|
620
|
+
"permission_id": permission.permissionId as Any,
|
|
621
|
+
"description": permission.description as Any,
|
|
622
|
+
"group": permission.group as Any,
|
|
623
|
+
"group_id": permission.groupId as Any,
|
|
624
|
+
"name_map": permission.nameMap as Any,
|
|
625
|
+
"is_settings_prompt_enabled": permission.isSettingsPromptEnabled as Any
|
|
626
|
+
]
|
|
627
|
+
|
|
628
|
+
// Convert to JSON data
|
|
629
|
+
let jsonData = try! JSONSerialization.data(withJSONObject: permissionData)
|
|
630
|
+
|
|
631
|
+
// Decode into ConsentUI.AppPermission
|
|
632
|
+
let nativePermission = try! JSONDecoder().decode(ConsentUI.AppPermission.self, from: jsonData)
|
|
633
|
+
|
|
634
|
+
return nativePermission
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
private func getString(_ map: [String : String]?) -> String {
|
|
638
|
+
return map?["_"] ?? ""
|
|
639
|
+
}
|
|
640
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* linguist-generated
|