react-native-cliqit 0.0.1

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 (39) hide show
  1. package/README.md +209 -0
  2. package/android/build.gradle +27 -0
  3. package/android/src/main/AndroidManifest.xml +1 -0
  4. package/android/src/main/java/com/cliqit/CliqItModule.kt +242 -0
  5. package/android/src/main/java/com/cliqit/CliqItPackage.kt +14 -0
  6. package/android/src/main/java/com/cliqit/sdk/CliqItDefaults.kt +17 -0
  7. package/android/src/main/java/com/cliqit/sdk/CliqItDeviceInfo.kt +196 -0
  8. package/android/src/main/java/com/cliqit/sdk/CliqItHttp.kt +98 -0
  9. package/android/src/main/java/com/cliqit/sdk/CliqItModels.kt +130 -0
  10. package/android/src/main/java/com/cliqit/sdk/CliqItSDK.kt +514 -0
  11. package/android/src/main/java/com/cliqit/sdk/CliqItWebFingerprint.kt +230 -0
  12. package/ios/CliqItModule.m +14 -0
  13. package/ios/CliqItModule.swift +238 -0
  14. package/ios/Frameworks/CliqIt.xcframework/Info.plist +44 -0
  15. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/CliqIt +0 -0
  16. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Headers/CliqIt-Swift.h +382 -0
  17. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Info.plist +0 -0
  18. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios.abi.json +12111 -0
  19. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios.private.swiftinterface +419 -0
  20. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  21. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios.swiftinterface +419 -0
  22. package/ios/Frameworks/CliqIt.xcframework/ios-arm64/CliqIt.framework/Modules/module.modulemap +3 -0
  23. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/CliqIt +0 -0
  24. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Headers/CliqIt-Swift.h +760 -0
  25. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Info.plist +0 -0
  26. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios-simulator.abi.json +12111 -0
  27. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +419 -0
  28. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  29. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/arm64-apple-ios-simulator.swiftinterface +419 -0
  30. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/x86_64-apple-ios-simulator.abi.json +12111 -0
  31. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +419 -0
  32. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  33. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/CliqIt.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +419 -0
  34. package/ios/Frameworks/CliqIt.xcframework/ios-arm64_x86_64-simulator/CliqIt.framework/Modules/module.modulemap +3 -0
  35. package/package.json +48 -0
  36. package/react-native-cliqit.podspec +27 -0
  37. package/react-native.config.js +11 -0
  38. package/src/index.d.ts +92 -0
  39. package/src/index.js +152 -0
package/src/index.js ADDED
@@ -0,0 +1,152 @@
1
+ import { NativeEventEmitter, NativeModules } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `CliqIt native module not found. Make sure the native module is linked (iOS pod / Android cliqit-native).`;
5
+
6
+ const NativeCliqIt = NativeModules.CliqItModule
7
+ ? NativeModules.CliqItModule
8
+ : new Proxy(
9
+ {},
10
+ {
11
+ get() {
12
+ throw new Error(LINKING_ERROR);
13
+ },
14
+ },
15
+ );
16
+
17
+ const emitter = new NativeEventEmitter(NativeCliqIt);
18
+
19
+ /** Mirrors native `CliqItLinkField` — use `details[LinkField.resolvedPath]`. */
20
+ export const LinkField = NativeCliqIt.LinkField ?? {
21
+ destination: 'destination',
22
+ iosDestination: 'iosDestination',
23
+ androidDestination: 'androidDestination',
24
+ ogTitle: 'ogTitle',
25
+ ogDescription: 'ogDescription',
26
+ ogImage: 'ogImage',
27
+ ogUrl: 'ogUrl',
28
+ slug: 'slug',
29
+ webFallback: 'webFallback',
30
+ showInterstitial: 'showInterstitial',
31
+ isDeepLink: 'isDeepLink',
32
+ appleTeamId: 'appleTeamId',
33
+ iosBundleId: 'iosBundleId',
34
+ androidPackageName: 'androidPackageName',
35
+ resolvedPath: 'resolvedPath',
36
+ };
37
+
38
+ /** @param {{ result?: any, error?: string | null }} payload */
39
+ function invoke(callback, payload) {
40
+ if (typeof callback !== 'function') return;
41
+ callback({
42
+ result: payload.result ?? null,
43
+ error: payload.error ?? null,
44
+ });
45
+ }
46
+
47
+ function listen(eventName, mapRaw, callback) {
48
+ if (typeof callback !== 'function') {
49
+ throw new Error(`CliqIt.${eventName}: pass ({ result, error }) => { ... }`);
50
+ }
51
+ const sub = emitter.addListener(eventName, (raw) => {
52
+ callback(mapRaw(raw));
53
+ });
54
+ return () => sub.remove();
55
+ }
56
+
57
+ function mapDeepLink(raw) {
58
+ return { result: raw ?? null, error: null };
59
+ }
60
+
61
+ function mapDeferredMatch(raw) {
62
+ if (!raw) return { result: null, error: 'Empty deferred match payload' };
63
+ if (raw.status === 'failed') {
64
+ return { result: null, error: raw.error || 'Deferred match failed' };
65
+ }
66
+ return { result: raw, error: null };
67
+ }
68
+
69
+ function mapLinkLookup(raw) {
70
+ if (!raw) return { result: null, error: 'Empty link lookup payload' };
71
+ if (raw.status === 'failed') {
72
+ return { result: null, error: raw.error || 'Link lookup failed' };
73
+ }
74
+ return { result: raw, error: null };
75
+ }
76
+
77
+ function mapVerify(raw) {
78
+ if (!raw) return { result: null, error: 'Empty verify payload' };
79
+ if (raw.status === 'failed') {
80
+ return { result: null, error: raw.error || raw.message || 'Verify failed' };
81
+ }
82
+ // ok + mismatch both come as result (mismatch is identity check, not transport error)
83
+ return { result: raw, error: null };
84
+ }
85
+
86
+ const CliqIt = {
87
+ LinkField,
88
+
89
+ /**
90
+ * @param {{ apiKey: string }} options
91
+ * @param {(payload: { result: { ok: true } | null, error: string | null }) => void} [callback]
92
+ */
93
+ configure(options = {}, callback) {
94
+ const apiKey = options?.apiKey;
95
+ if (!apiKey || typeof apiKey !== 'string') {
96
+ invoke(callback, { result: null, error: 'apiKey is required' });
97
+ return;
98
+ }
99
+ try {
100
+ NativeCliqIt.configure(apiKey);
101
+ invoke(callback, { result: { ok: true }, error: null });
102
+ } catch (e) {
103
+ invoke(callback, {
104
+ result: null,
105
+ error: e?.message || String(e),
106
+ });
107
+ }
108
+ },
109
+
110
+ /**
111
+ * @param {{ url: string }} options
112
+ * @param {(payload: { result: { ok: true, url: string } | null, error: string | null }) => void} [callback]
113
+ */
114
+ handleUrl(options = {}, callback) {
115
+ const url = options?.url;
116
+ if (!url || typeof url !== 'string') {
117
+ invoke(callback, { result: null, error: 'url is required' });
118
+ return;
119
+ }
120
+ try {
121
+ NativeCliqIt.handleUrl(url);
122
+ invoke(callback, { result: { ok: true, url }, error: null });
123
+ } catch (e) {
124
+ invoke(callback, {
125
+ result: null,
126
+ error: e?.message || String(e),
127
+ });
128
+ }
129
+ },
130
+
131
+ /** @param {(payload: { result: object | null, error: string | null }) => void} callback */
132
+ onDeepLink(callback) {
133
+ return listen('CliqItDeepLink', mapDeepLink, callback);
134
+ },
135
+
136
+ /** @param {(payload: { result: object | null, error: string | null }) => void} callback */
137
+ onDeferredMatch(callback) {
138
+ return listen('CliqItDeferredMatch', mapDeferredMatch, callback);
139
+ },
140
+
141
+ /** @param {(payload: { result: object | null, error: string | null }) => void} callback */
142
+ onLinkLookup(callback) {
143
+ return listen('CliqItLinkLookup', mapLinkLookup, callback);
144
+ },
145
+
146
+ /** @param {(payload: { result: object | null, error: string | null }) => void} callback */
147
+ onVerify(callback) {
148
+ return listen('CliqItVerify', mapVerify, callback);
149
+ },
150
+ };
151
+
152
+ export default CliqIt;