@commandersact/tcconsent-react-native 1.4.2-beta.42

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.
Files changed (38) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +112 -0
  3. package/android/build.gradle +93 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/tcconsentreactnative/TCConsentReactNativeGenerated.java +10 -0
  8. package/android/src/main/java/com/tcconsentreactnative/TcconsentReactNativeModule.java +460 -0
  9. package/android/src/main/java/com/tcconsentreactnative/TcconsentReactNativePackage.java +28 -0
  10. package/android/src/main/proguard-rules.pro +2 -0
  11. package/ios/TCConsentGenerated.swift +10 -0
  12. package/ios/TcconsentReactNative-Bridging-Header.h +2 -0
  13. package/ios/TcconsentReactNative.mm +48 -0
  14. package/ios/TcconsentReactNative.swift +331 -0
  15. package/lib/commonjs/TCConsent.js +190 -0
  16. package/lib/commonjs/TCConsent.js.map +1 -0
  17. package/lib/commonjs/TCConsentAPI.js +125 -0
  18. package/lib/commonjs/TCConsentAPI.js.map +1 -0
  19. package/lib/commonjs/index.js +28 -0
  20. package/lib/commonjs/index.js.map +1 -0
  21. package/lib/module/TCConsent.js +164 -0
  22. package/lib/module/TCConsent.js.map +1 -0
  23. package/lib/module/TCConsentAPI.js +118 -0
  24. package/lib/module/TCConsentAPI.js.map +1 -0
  25. package/lib/module/index.js +3 -0
  26. package/lib/module/index.js.map +1 -0
  27. package/lib/typescript/TCConsent.d.ts +74 -0
  28. package/lib/typescript/TCConsent.d.ts.map +1 -0
  29. package/lib/typescript/TCConsentAPI.d.ts +82 -0
  30. package/lib/typescript/TCConsentAPI.d.ts.map +1 -0
  31. package/lib/typescript/index.d.ts +3 -0
  32. package/lib/typescript/index.d.ts.map +1 -0
  33. package/package.json +177 -0
  34. package/src/TCConsent.tsx +225 -0
  35. package/src/TCConsentAPI.tsx +131 -0
  36. package/src/index.tsx +2 -0
  37. package/tcconsent-react-native-swift.podspec +28 -0
  38. package/tcconsent-react-native.podspec +27 -0
package/package.json ADDED
@@ -0,0 +1,177 @@
1
+ {
2
+ "name": "@commandersact/tcconsent-react-native",
3
+ "version": "1.4.2-beta.42",
4
+ "description": " Commanders Act's TCConsent SDK bridge for react native",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/typescript/index.d.ts",
13
+ "import": "./lib/module/index.js",
14
+ "require": "./lib/commonjs/index.js",
15
+ "react-native": "./src/index.tsx"
16
+ }
17
+ },
18
+ "files": [
19
+ "src",
20
+ "lib",
21
+ "android",
22
+ "ios",
23
+ "cpp",
24
+ "*.podspec",
25
+ "!lib/typescript/example",
26
+ "!ios/build",
27
+ "!android/build",
28
+ "!android/gradle",
29
+ "!android/gradlew",
30
+ "!android/gradlew.bat",
31
+ "!android/local.properties",
32
+ "!**/__tests__",
33
+ "!**/__fixtures__",
34
+ "!**/__mocks__",
35
+ "!**/.*"
36
+ ],
37
+ "expo": {
38
+ "plugin": "./app.plugin.js"
39
+ },
40
+ "scripts": {
41
+ "test": "jest",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
44
+ "prepack": "bob build",
45
+ "release": "release-it",
46
+ "example": "yarn --cwd example",
47
+ "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
48
+ "build:ios": "cd example/ios && xcodebuild -workspace TcserversideExample.xcworkspace -scheme TcserversideExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
49
+ "bootstrap": "yarn example && yarn install && yarn example pods",
50
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
51
+ },
52
+ "keywords": [
53
+ "react-native",
54
+ "ios",
55
+ "android"
56
+ ],
57
+ "repository": "https://github.com/CommandersAct/ReactNativeBridge",
58
+ "author": "CommandersAct <mobile@commandersact.com> (https://www.commandersact.com/)",
59
+ "license": "MIT",
60
+ "bugs": {
61
+ "url": "https://github.com/CommandersAct/ReactNativeBridge/issues"
62
+ },
63
+ "homepage": "https://github.com/CommandersAct/ReactNativeBridge#readme",
64
+ "publishConfig": {
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "devDependencies": {
68
+ "@commitlint/config-conventional": "^17.0.2",
69
+ "@evilmartians/lefthook": "^1.2.2",
70
+ "@react-native-community/eslint-config": "^3.0.2",
71
+ "@release-it/conventional-changelog": "^5.0.0",
72
+ "@types/jest": "^28.1.2",
73
+ "@types/react": "~17.0.21",
74
+ "@types/react-native": "0.70.0",
75
+ "commitlint": "^17.0.2",
76
+ "del-cli": "^5.0.0",
77
+ "eslint": "^8.4.1",
78
+ "eslint-config-prettier": "^8.5.0",
79
+ "eslint-plugin-prettier": "^4.0.0",
80
+ "jest": "^28.1.1",
81
+ "pod-install": "^0.1.0",
82
+ "prettier": "^2.0.5",
83
+ "react": "18.2.0",
84
+ "react-native": "^0.72.4",
85
+ "react-native-builder-bob": "^0.21.3",
86
+ "release-it": "^15.0.0",
87
+ "turbo": "^1.10.7",
88
+ "typescript": "^5.0.2",
89
+ "@commandersact/tccore-react-native": "1.3.2-beta.23"
90
+ },
91
+ "dependencies": {},
92
+ "resolutions": {
93
+ "@types/react": "17.0.21"
94
+ },
95
+ "peerDependencies": {
96
+ "react": "*",
97
+ "react-native": "*",
98
+ "@commandersact/tccore-react-native": "1.3.2-beta.23"
99
+ },
100
+ "engines": {
101
+ "node": ">= 16.0.0"
102
+ },
103
+ "packageManager": "^yarn@1.22.15",
104
+ "jest": {
105
+ "preset": "react-native",
106
+ "modulePathIgnorePatterns": [
107
+ "<rootDir>/example/node_modules",
108
+ "<rootDir>/lib/"
109
+ ]
110
+ },
111
+ "commitlint": {
112
+ "extends": [
113
+ "@commitlint/config-conventional"
114
+ ]
115
+ },
116
+ "release-it": {
117
+ "git": {
118
+ "commitMessage": "chore: release ${version}",
119
+ "tagName": "v${version}"
120
+ },
121
+ "npm": {
122
+ "publish": true
123
+ },
124
+ "github": {
125
+ "release": true
126
+ },
127
+ "plugins": {
128
+ "@release-it/conventional-changelog": {
129
+ "preset": "angular"
130
+ }
131
+ }
132
+ },
133
+ "eslintConfig": {
134
+ "root": true,
135
+ "extends": [
136
+ "@react-native-community",
137
+ "prettier"
138
+ ],
139
+ "rules": {
140
+ "prettier/prettier": [
141
+ "error",
142
+ {
143
+ "quoteProps": "consistent",
144
+ "singleQuote": true,
145
+ "tabWidth": 2,
146
+ "trailingComma": "es5",
147
+ "useTabs": false
148
+ }
149
+ ]
150
+ }
151
+ },
152
+ "eslintIgnore": [
153
+ "node_modules/",
154
+ "lib/"
155
+ ],
156
+ "prettier": {
157
+ "quoteProps": "consistent",
158
+ "singleQuote": true,
159
+ "tabWidth": 2,
160
+ "trailingComma": "es5",
161
+ "useTabs": false
162
+ },
163
+ "react-native-builder-bob": {
164
+ "source": "src",
165
+ "output": "lib",
166
+ "targets": [
167
+ "commonjs",
168
+ "module",
169
+ [
170
+ "typescript",
171
+ {
172
+ "project": "tsconfig.build.json"
173
+ }
174
+ ]
175
+ ]
176
+ }
177
+ }
@@ -0,0 +1,225 @@
1
+ import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
2
+ import { TCUserInstance } from '@commandersact/tccore-react-native';
3
+
4
+ const LINKING_ERROR =
5
+ `The package 'tcconsent-react-native' doesn't seem to be linked. Make sure: \n\n` +
6
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
+ '- You rebuilt the app after installing the package\n' +
8
+ '- You are not using Expo Go\n';
9
+
10
+ export const TCConsentBridge = NativeModules.TcconsentReactNative
11
+ ? NativeModules.TcconsentReactNative
12
+ : new Proxy(
13
+ {},
14
+ {
15
+ get() {
16
+ throw new Error(LINKING_ERROR);
17
+ },
18
+ }
19
+ );
20
+
21
+ const eventEmitter = new NativeEventEmitter(TCConsentBridge);
22
+ eventEmitter.addListener('consentUpdated', _ => {});
23
+ eventEmitter.addListener('consentOutdated', _ => {});
24
+ eventEmitter.addListener('consentCategoryChanged', _ => {});
25
+ eventEmitter.addListener('significantChangesInPrivacy', _ => {});
26
+ eventEmitter.addListener('refreshTCUser', refreshTCUser);
27
+
28
+
29
+ /**
30
+ * Initialise your TCConsent module with your own siteID/privacyID values
31
+ *
32
+ * @param siteId
33
+ * @param privacyID
34
+ */
35
+ export async function setSiteIDPrivacyID(siteId: number, privacyID: number)
36
+ {
37
+ await TCConsentBridge.setSiteIDPrivacyID(siteId, privacyID);
38
+ }
39
+
40
+ export function acceptAllConsent()
41
+ {
42
+ TCConsentBridge.acceptAllConsent();
43
+ }
44
+
45
+ export function refuseAllConsent()
46
+ {
47
+ TCConsentBridge.refuseAllConsent();
48
+ }
49
+
50
+ /**
51
+ * Show the Privacy Center with the specified options.
52
+ *
53
+ * @param {EPrivacyCenterStartScreen} startScreen - The starting screen for the Privacy Center, could be kTCStartWithVendorScreen or kTCStartWithPurposeScreen.
54
+ * @param {string | null} customAndroidTitle - Optional title value for your privacy center activity on android.
55
+ * @returns {void}
56
+ */
57
+ export function showPrivacyCenter(startScreen: EPrivacyCenterStartScreen = EPrivacyCenterStartScreen.kTCStartWithDefault, customAndroidTitle:string | null = null)
58
+ {
59
+ if (Platform.OS === 'ios')
60
+ {
61
+ TCConsentBridge.showPrivacyCenter(startScreen);
62
+ }
63
+ else if (Platform.OS === 'android')
64
+ {
65
+ TCConsentBridge.showPrivacyCenter(startScreen, customAndroidTitle);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Enable google ACString usage [IAB Users only]
71
+ *
72
+ * @param useACString boolean value.
73
+ */
74
+ export function useACString(useACString: boolean)
75
+ {
76
+ TCConsentBridge.useACString(useACString);
77
+ }
78
+
79
+
80
+
81
+ export function setConsentDuration(months: number)
82
+ {
83
+ TCConsentBridge.setConsentDuration(months);
84
+ }
85
+
86
+ export function useCustomPublisherRestrictions()
87
+ {
88
+ TCConsentBridge.useCustomPublisherRestrictions();
89
+ }
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ export function statEnterPCToVendorScreen()
98
+ {
99
+ TCConsentBridge.statEnterPCToVendorScreen();
100
+ }
101
+
102
+ export function statShowVendorScreen()
103
+ {
104
+ TCConsentBridge.statShowVendorScreen();
105
+ }
106
+
107
+ export function statViewPrivacyPoliciesFromPrivacyCenter()
108
+ {
109
+ TCConsentBridge.statViewPrivacyPoliciesFromPrivacyCenter();
110
+ }
111
+
112
+ export function statViewPrivacyCenter()
113
+ {
114
+ TCConsentBridge.statViewPrivacyCenter();
115
+ }
116
+
117
+ export function statViewBanner()
118
+ {
119
+ TCConsentBridge.statViewBanner();
120
+ }
121
+
122
+ export async function getConsentAsJson(): Promise<string>
123
+ {
124
+ return TCConsentBridge.consentAsJson();
125
+ }
126
+
127
+ export async function resetSavedConsent()
128
+ {
129
+ TCConsentBridge.resetSavedConsent();
130
+ }
131
+
132
+ export async function setLanguage(languageCode: string)
133
+ {
134
+ return TCConsentBridge.setLanguage(languageCode);
135
+ }
136
+
137
+ export async function statViewPrivacyPoliciesFromBanner()
138
+ {
139
+ return TCConsentBridge.statViewPrivacyPoliciesFromBanner();
140
+ }
141
+
142
+ /**
143
+ * fetches TCConsent.consentVersion on the device.
144
+ *
145
+ * @returns a Promise for the consentVersion native value.
146
+ */
147
+ export async function getConsentVersion(): Promise<string>
148
+ {
149
+ return TCConsentBridge.getConsentVersion();
150
+ }
151
+
152
+ /**
153
+ * set consentVersion manually for your privacy hits.
154
+ *
155
+ * @param consentVersion string value.
156
+ */
157
+ export async function setConsentVersion(consentVersion: string)
158
+ {
159
+ TCConsentBridge.setConsentVersion(consentVersion);
160
+ }
161
+
162
+ /**
163
+ * set TCConsent.do_not_track value for your privacy hits.
164
+ *
165
+ * @param value boolean value.
166
+ */
167
+ export async function do_not_track(value: boolean)
168
+ {
169
+ TCConsentBridge.do_not_track(value);
170
+ }
171
+
172
+ /**
173
+ * Android OS only ! disable the back button on your privacy center.
174
+ *
175
+ * @param value boolean value, true for enabled button, false for disabled.
176
+ */
177
+ export async function deactivateBackButton(value: boolean)
178
+ {
179
+ if (Platform.OS === 'android')
180
+ {
181
+ TCConsentBridge.deactivateBackButton(value)
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Sets the consent switches state first time privacy center is shown.
187
+ *
188
+ * @param value boolean value, true for enabled switch per default, false for disabled.
189
+
190
+ export async function switchDefaultState(value: boolean)
191
+ {
192
+ TCConsentBridge.switchDefaultState(value)
193
+ }*/
194
+
195
+ function refreshTCUser(userScheme: any)
196
+ {
197
+ if (Platform.OS === 'ios')
198
+ {
199
+ TCUserInstance.initValues(userScheme)
200
+ }
201
+ else if (Platform.OS === 'android')
202
+ {
203
+ TCUserInstance.initValues(JSON.parse(userScheme as string))
204
+ }
205
+ }
206
+
207
+ export enum ETCConsentSource
208
+ {
209
+ POP_UP = 'POP_UP',
210
+ PRIVACY_CENTER = 'PRIVACY_CENTER'
211
+ }
212
+
213
+ export enum ETCConsentAction
214
+ {
215
+ ACCEPT_ALL = 'ACCEPT_ALL',
216
+ REFUSE_ALL = 'REFUSE_ALL',
217
+ SAVE = 'SAVE'
218
+ }
219
+
220
+ export enum EPrivacyCenterStartScreen
221
+ {
222
+ kTCStartWithVendorScreen = 'startWithVendorScreen',
223
+ kTCStartWithPurposeScreen = 'startWithPurposeScreen',
224
+ kTCStartWithDefault = 'kTCStartWithDefault'
225
+ }
@@ -0,0 +1,131 @@
1
+ import { TCConsentBridge } from "./TCConsent";
2
+
3
+ export class TCConsentAPI
4
+ {
5
+ /**
6
+ * Checks if kTCPrivacyConsent is empty.
7
+ *
8
+ * @return true if the consent was already given, false otherwise.
9
+ */
10
+ public static isConsentAlreadyGiven(): Promise<boolean>
11
+ {
12
+ return TCConsentBridge.isConsentAlreadyGiven();
13
+ }
14
+
15
+ /**
16
+ * Return the epochformatted timestamp of the last time the consent was saved.
17
+ *
18
+ * @return epochformatted timestamp or 0.
19
+ */
20
+ public static getLastTimeConsentWasSaved(): Promise<number>
21
+ {
22
+ return TCConsentBridge.getLastTimeConsentWasSaved();
23
+ }
24
+
25
+ /**
26
+ * Check if a Category has been accepted.
27
+ *
28
+ * @param ID the category ID.
29
+ * @return true or false.
30
+ */
31
+ public static isCategoryAccepted(ID: number): Promise<boolean>
32
+ {
33
+ return TCConsentBridge.isCategoryAccepted(ID);
34
+ }
35
+
36
+ /**
37
+ * Check if a vendor has been accepted.
38
+ *
39
+ * @param ID the vendor ID.
40
+ * @return true or false.
41
+ */
42
+ public static isVendorAccepted(ID: number): Promise<boolean>
43
+ {
44
+ return TCConsentBridge.isVendorAccepted(ID);
45
+ }
46
+
47
+ /**
48
+ * Check if a purpose has been accepted.
49
+ *
50
+ * @param ID the purpose ID.
51
+ * @return true or false.
52
+ */
53
+ public static isIABPurposeAccepted(ID: number): Promise<boolean>
54
+ {
55
+ return TCConsentBridge.isIABPurposeAccepted(ID);
56
+ }
57
+
58
+ /**
59
+ * Check if a vendor has been accepted.
60
+ *
61
+ * @param ID the vendor ID.
62
+ * @return true or false.
63
+ */
64
+ public static isIABVendorAccepted(ID: number): Promise<boolean>
65
+ {
66
+ return TCConsentBridge.isIABVendorAccepted(ID);
67
+ }
68
+
69
+ /**
70
+ * Check if a special feature has been accepted.
71
+ *
72
+ * @param ID the vendor ID.
73
+ * @param appContext the application context.
74
+ * @return true or false.
75
+ */
76
+ public static isIABSpecialFeatureAccepted(ID: number): Promise<boolean>
77
+ {
78
+ return TCConsentBridge.isIABSpecialFeatureAccepted(ID);
79
+ }
80
+
81
+ /**
82
+ * Get the list of all accepted categories.
83
+ *
84
+ * @return a List of PRIVACY_CAT_IDs.
85
+ */
86
+ public static getAcceptedCategories(): Promise<Array<String>>
87
+ {
88
+ return TCConsentBridge.getAcceptedCategories();
89
+ }
90
+
91
+ /**
92
+ * Get the list of all accepted vendors.
93
+ *
94
+ * @return a List of PRIVACY_VEN_IDs.
95
+ */
96
+ public static getAcceptedVendors(): Promise<Array<String>>
97
+ {
98
+ return TCConsentBridge.getAcceptedVendors();
99
+ }
100
+
101
+ /**
102
+ * Get the list of all accepted vendors.
103
+ *
104
+ * @return a List of acm_IDs.
105
+ */
106
+ public static getAcceptedGoogleVendors(): Promise<Array<String>>
107
+ {
108
+ return TCConsentBridge.getAcceptedGoogleVendors();
109
+ }
110
+
111
+ /**
112
+ * Get the list of everything that was accepted.
113
+ *
114
+ * @param appContext the application context.
115
+ * @return a List of PRIVACY_VEN_IDs and PRIVACY_CAT_IDs.
116
+ */
117
+ public static getAllAcceptedConsent(): Promise<Array<String>>
118
+ {
119
+ return TCConsentBridge.getAllAcceptedConsent();
120
+ }
121
+
122
+ /**
123
+ * Checks if we should display privacy center for any reason.
124
+ * @param context the application context.
125
+ * @return True or False.
126
+ */
127
+ public static shouldDisplayPrivacyCenter(): Promise<boolean>
128
+ {
129
+ return TCConsentBridge.shouldDisplayPrivacyCenter();
130
+ }
131
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,2 @@
1
+ export { TCConsentAPI } from './TCConsentAPI';
2
+ export * from './TCConsent';
@@ -0,0 +1,28 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "tcconsent-react-native-swift"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ Commanders Act React Native Bridge
11
+ DESC
12
+ s.homepage = "https://github.com/commandersact/tcconsent-react-native"
13
+ s.license = { :type => "Commercial", :file => "LICENSE" }
14
+ s.authors = { "CommandersAct" => "mobile@commandersact.com" }
15
+ s.platforms = { :ios => "11.0" }
16
+ s.source = { :git => "https://github.com/commandersact/tcconsent-react-native.git", :tag => "#{s.version}" }
17
+ s.source_files = "ios/**/*.{swift}"
18
+ s.requires_arc = true
19
+ s.swift_version = "5.0"
20
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21
+
22
+ s.dependency 'tcconsent-react-native'
23
+ s.dependency 'IOSV5-TCCore', '5.4.5'
24
+ s.dependency 'TCConsent', '5.3.8'
25
+ s.dependency 'TCIAB', '5.2.0'
26
+
27
+ end
28
+
@@ -0,0 +1,27 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "tcconsent-react-native"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ Commanders Act React Native Bridge
11
+ DESC
12
+ s.homepage = "https://github.com/commandersact/tcconsent-react-native"
13
+ s.license = { :type => "Commercial", :file => "LICENSE" }
14
+ s.authors = { "CommandersAct" => "mobile@commandersact.com" }
15
+ s.platforms = { :ios => "11.0" }
16
+ s.source = { :git => "https://github.com/commandersact/tcconsent-react-native.git", :tag => "#{s.version}" }
17
+ s.source_files = "ios/**/*.{h,c,m,mm}"
18
+ s.requires_arc = true
19
+ s.swift_version = "5.0"
20
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21
+
22
+ s.dependency 'React-Core'
23
+ s.dependency 'IOSV5-TCCore', '5.4.5'
24
+ s.dependency 'TCConsent', '5.3.8'
25
+ s.dependency 'TCIAB', '5.2.0'
26
+
27
+ end