@snaplyagent/react-native 0.0.0-stage → 1.1.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +7 -0
  3. package/README.md +139 -2
  4. package/SnaplyAgentReactNative.podspec +24 -0
  5. package/android/build.gradle +33 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/com/snaplyagent/reactnative/SnaplyAgentModule.kt +104 -0
  8. package/android/src/main/java/com/snaplyagent/reactnative/SnaplyAgentPackage.kt +26 -0
  9. package/ios/Frameworks/SnaplyAgent.xcframework/Info.plist +44 -0
  10. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/Headers/SnaplyAgent-Swift.h +382 -0
  11. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/Info.plist +0 -0
  12. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  13. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/arm64-apple-ios.swiftinterface +175 -0
  14. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/Modules/module.modulemap +3 -0
  15. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/PrivacyInfo.xcprivacy +149 -0
  16. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/SnaplyAgent +0 -0
  17. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/en.lproj/Snaply.strings +0 -0
  18. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/hy.lproj/Snaply.strings +0 -0
  19. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64/SnaplyAgent.framework/ru.lproj/Snaply.strings +0 -0
  20. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Headers/SnaplyAgent-Swift.h +760 -0
  21. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Info.plist +0 -0
  22. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftinterface +175 -0
  24. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  25. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +175 -0
  26. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/Modules/module.modulemap +3 -0
  27. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/PrivacyInfo.xcprivacy +149 -0
  28. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/SnaplyAgent +0 -0
  29. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/_CodeSignature/CodeResources +233 -0
  30. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/en.lproj/Snaply.strings +0 -0
  31. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/hy.lproj/Snaply.strings +0 -0
  32. package/ios/Frameworks/SnaplyAgent.xcframework/ios-arm64_x86_64-simulator/SnaplyAgent.framework/ru.lproj/Snaply.strings +0 -0
  33. package/ios/Sources/SnaplyAgentModule.h +5 -0
  34. package/ios/Sources/SnaplyAgentModule.mm +142 -0
  35. package/ios/Sources/SnaplyBridge.swift +123 -0
  36. package/lib/SnaplyRedact.d.ts +9 -0
  37. package/lib/index.d.ts +86 -0
  38. package/lib/index.js +1 -0
  39. package/package.json +43 -4
  40. package/spec/NativeSnaplyAgent.ts +41 -0
@@ -0,0 +1,233 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Headers/SnaplyAgent-Swift.h</key>
8
+ <data>
9
+ RiYQbaoXh5PG73T6yE6Y+A8cT34=
10
+ </data>
11
+ <key>Info.plist</key>
12
+ <data>
13
+ HR50EHNp+oxy61UsNCK3Ofzze4o=
14
+ </data>
15
+ <key>Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
16
+ <data>
17
+ G8l2tGnl5hJ1Oi80Z03QFWmMhRQ=
18
+ </data>
19
+ <key>Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
20
+ <data>
21
+ bmOLNLvHnfAJyhbDRcYbzuTnIBk=
22
+ </data>
23
+ <key>Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
24
+ <data>
25
+ o0RrUHqmG43itbFV4uDNVvwHio8=
26
+ </data>
27
+ <key>Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
28
+ <data>
29
+ d0LiN97BuLjHYqL7EHE7Ke1XU9U=
30
+ </data>
31
+ <key>Modules/module.modulemap</key>
32
+ <data>
33
+ BkgBoyLrGEp7Ain5gk2pH+WzLLw=
34
+ </data>
35
+ <key>PrivacyInfo.xcprivacy</key>
36
+ <data>
37
+ iInK0QW/gTHe5D9wF1A+Z+W08KI=
38
+ </data>
39
+ <key>en.lproj/Snaply.strings</key>
40
+ <dict>
41
+ <key>hash</key>
42
+ <data>
43
+ 2zcHbxH4+Rdn2AR0FQX3hMWqSeI=
44
+ </data>
45
+ <key>optional</key>
46
+ <true/>
47
+ </dict>
48
+ <key>hy.lproj/Snaply.strings</key>
49
+ <dict>
50
+ <key>hash</key>
51
+ <data>
52
+ cjViaWyGy1qQAaf6AAtG490Mh7Q=
53
+ </data>
54
+ <key>optional</key>
55
+ <true/>
56
+ </dict>
57
+ <key>ru.lproj/Snaply.strings</key>
58
+ <dict>
59
+ <key>hash</key>
60
+ <data>
61
+ yTdt9T8lLTXrd+sCvPz7Ud8l09o=
62
+ </data>
63
+ <key>optional</key>
64
+ <true/>
65
+ </dict>
66
+ </dict>
67
+ <key>files2</key>
68
+ <dict>
69
+ <key>Headers/SnaplyAgent-Swift.h</key>
70
+ <dict>
71
+ <key>hash2</key>
72
+ <data>
73
+ RV+2wkjeinZ9DqaLutiFs7HKjuM7yTanKKDVqtW4Xzs=
74
+ </data>
75
+ </dict>
76
+ <key>Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
77
+ <dict>
78
+ <key>hash2</key>
79
+ <data>
80
+ SWqriQVsx+DCT1LzzQ3WFYwOATmW2Ir/NQG1T68ARk4=
81
+ </data>
82
+ </dict>
83
+ <key>Modules/SnaplyAgent.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
84
+ <dict>
85
+ <key>hash2</key>
86
+ <data>
87
+ aq0Mjq60xMHTcxRRM0ddRS9YIzfrtnI30PUclAwGzwY=
88
+ </data>
89
+ </dict>
90
+ <key>Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
91
+ <dict>
92
+ <key>hash2</key>
93
+ <data>
94
+ 5kmpGuJ1CR3Q93I2yxNGtcygKcXei9Kcj4YXqImBi+o=
95
+ </data>
96
+ </dict>
97
+ <key>Modules/SnaplyAgent.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
98
+ <dict>
99
+ <key>hash2</key>
100
+ <data>
101
+ 4Q4Ti/W4hddXbjXppLzBth/u8J19fyDN3bPFPYYSTyI=
102
+ </data>
103
+ </dict>
104
+ <key>Modules/module.modulemap</key>
105
+ <dict>
106
+ <key>hash2</key>
107
+ <data>
108
+ X/fO95VdmSmYR1VBUYjDIvlX4Gb7WnF3/yo14+14Olo=
109
+ </data>
110
+ </dict>
111
+ <key>PrivacyInfo.xcprivacy</key>
112
+ <dict>
113
+ <key>hash2</key>
114
+ <data>
115
+ q2hvdlChgzta8lSTT8THZ5RhGBpXdcl9Y7Kq8H78pZc=
116
+ </data>
117
+ </dict>
118
+ <key>en.lproj/Snaply.strings</key>
119
+ <dict>
120
+ <key>hash2</key>
121
+ <data>
122
+ HoER21GAMCbu9eHHOnwfKUtkO554CWG+s+0li4bG6tI=
123
+ </data>
124
+ <key>optional</key>
125
+ <true/>
126
+ </dict>
127
+ <key>hy.lproj/Snaply.strings</key>
128
+ <dict>
129
+ <key>hash2</key>
130
+ <data>
131
+ yb0JC6iClWHXjX2lniKqtlvJYxqEemWIq1rPpbzTGBA=
132
+ </data>
133
+ <key>optional</key>
134
+ <true/>
135
+ </dict>
136
+ <key>ru.lproj/Snaply.strings</key>
137
+ <dict>
138
+ <key>hash2</key>
139
+ <data>
140
+ YveeOb+JIZjIkMm6Hrc+B41deMuXl9JvqyXhEORSB44=
141
+ </data>
142
+ <key>optional</key>
143
+ <true/>
144
+ </dict>
145
+ </dict>
146
+ <key>rules</key>
147
+ <dict>
148
+ <key>^.*</key>
149
+ <true/>
150
+ <key>^.*\.lproj/</key>
151
+ <dict>
152
+ <key>optional</key>
153
+ <true/>
154
+ <key>weight</key>
155
+ <real>1000</real>
156
+ </dict>
157
+ <key>^.*\.lproj/locversion.plist$</key>
158
+ <dict>
159
+ <key>omit</key>
160
+ <true/>
161
+ <key>weight</key>
162
+ <real>1100</real>
163
+ </dict>
164
+ <key>^Base\.lproj/</key>
165
+ <dict>
166
+ <key>weight</key>
167
+ <real>1010</real>
168
+ </dict>
169
+ <key>^version.plist$</key>
170
+ <true/>
171
+ </dict>
172
+ <key>rules2</key>
173
+ <dict>
174
+ <key>.*\.dSYM($|/)</key>
175
+ <dict>
176
+ <key>weight</key>
177
+ <real>11</real>
178
+ </dict>
179
+ <key>^(.*/)?\.DS_Store$</key>
180
+ <dict>
181
+ <key>omit</key>
182
+ <true/>
183
+ <key>weight</key>
184
+ <real>2000</real>
185
+ </dict>
186
+ <key>^.*</key>
187
+ <true/>
188
+ <key>^.*\.lproj/</key>
189
+ <dict>
190
+ <key>optional</key>
191
+ <true/>
192
+ <key>weight</key>
193
+ <real>1000</real>
194
+ </dict>
195
+ <key>^.*\.lproj/locversion.plist$</key>
196
+ <dict>
197
+ <key>omit</key>
198
+ <true/>
199
+ <key>weight</key>
200
+ <real>1100</real>
201
+ </dict>
202
+ <key>^Base\.lproj/</key>
203
+ <dict>
204
+ <key>weight</key>
205
+ <real>1010</real>
206
+ </dict>
207
+ <key>^Info\.plist$</key>
208
+ <dict>
209
+ <key>omit</key>
210
+ <true/>
211
+ <key>weight</key>
212
+ <real>20</real>
213
+ </dict>
214
+ <key>^PkgInfo$</key>
215
+ <dict>
216
+ <key>omit</key>
217
+ <true/>
218
+ <key>weight</key>
219
+ <real>20</real>
220
+ </dict>
221
+ <key>^embedded\.provisionprofile$</key>
222
+ <dict>
223
+ <key>weight</key>
224
+ <real>20</real>
225
+ </dict>
226
+ <key>^version\.plist$</key>
227
+ <dict>
228
+ <key>weight</key>
229
+ <real>20</real>
230
+ </dict>
231
+ </dict>
232
+ </dict>
233
+ </plist>
@@ -0,0 +1,5 @@
1
+ // Copyright © 2026 iFixgroup. All rights reserved.
2
+ #import <SnaplyAgentSpec/SnaplyAgentSpec.h>
3
+
4
+ @interface SnaplyAgentModule : NativeSnaplyAgentSpecBase <NativeSnaplyAgentSpec>
5
+ @end
@@ -0,0 +1,142 @@
1
+ // Copyright © 2026 iFixgroup. All rights reserved.
2
+ #import "SnaplyAgentModule.h"
3
+
4
+ #import <QuartzCore/QuartzCore.h>
5
+ #import <React/RCTConversions.h>
6
+ #import <React/RCTTouchableComponentViewProtocol.h>
7
+ #import <react/renderer/components/view/TouchEventEmitter.h>
8
+
9
+ #if __has_include(<SnaplyAgentReactNative/SnaplyAgentReactNative-Swift.h>)
10
+ #import <SnaplyAgentReactNative/SnaplyAgentReactNative-Swift.h>
11
+ #else
12
+ #import "SnaplyAgentReactNative-Swift.h"
13
+ #endif
14
+
15
+ using namespace facebook::react;
16
+
17
+ static const int SnaplyRelayedTouchIdentifier = 16;
18
+
19
+ static BOOL SnaplyRelayTap(UIView *surface, CGPoint point)
20
+ {
21
+ UIView *view = [surface hitTest:point withEvent:nil];
22
+ while (view != nil && ![view respondsToSelector:@selector(touchEventEmitterAtPoint:)]) {
23
+ view = view.superview;
24
+ }
25
+ if (view == nil) {
26
+ return NO;
27
+ }
28
+ CGPoint local = [surface convertPoint:point toView:view];
29
+ SharedTouchEventEmitter emitter = [(id<RCTTouchableComponentViewProtocol>)view touchEventEmitterAtPoint:local];
30
+ if (!emitter) {
31
+ return NO;
32
+ }
33
+
34
+ Touch touch = {};
35
+ touch.identifier = SnaplyRelayedTouchIdentifier;
36
+ touch.target = (Tag)view.tag;
37
+ touch.offsetPoint = RCTPointFromCGPoint(local);
38
+ touch.pagePoint = RCTPointFromCGPoint(point);
39
+ touch.screenPoint = RCTPointFromCGPoint([surface convertPoint:point toCoordinateSpace:surface.window.screen.coordinateSpace]);
40
+ touch.timestamp = CACurrentMediaTime();
41
+ touch.timeStamp = RCTHighResTimeStampFromSeconds(touch.timestamp);
42
+
43
+ TouchEvent start = {};
44
+ start.touches.insert(touch);
45
+ start.changedTouches.insert(touch);
46
+ start.targetTouches.insert(touch);
47
+ emitter->onTouchStart(start);
48
+
49
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.08 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
50
+ Touch lifted = touch;
51
+ lifted.timestamp = CACurrentMediaTime();
52
+ lifted.timeStamp = RCTHighResTimeStampFromSeconds(lifted.timestamp);
53
+ TouchEvent end = {};
54
+ end.changedTouches.insert(lifted);
55
+ emitter->onTouchEnd(end);
56
+ });
57
+ return YES;
58
+ }
59
+
60
+ @implementation SnaplyAgentModule
61
+
62
+ + (NSString *)moduleName
63
+ {
64
+ return @"SnaplyAgent";
65
+ }
66
+
67
+ - (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
68
+ {
69
+ return std::make_shared<NativeSnaplyAgentSpecJSI>(params);
70
+ }
71
+
72
+ - (void)configure:(NSString *)key
73
+ host:(NSString *)host
74
+ userId:(NSString *)userId
75
+ userName:(NSString *)userName
76
+ collectVendorId:(BOOL)collectVendorId
77
+ language:(NSString *)language
78
+ serverKeys:(NSArray *)serverKeys
79
+ resolve:(RCTPromiseResolveBlock)resolve
80
+ reject:(RCTPromiseRejectBlock)reject
81
+ {
82
+ __weak SnaplyAgentModule *weakSelf = self;
83
+ SnaplyBridge.emit = ^(NSDictionary<NSString *, id> *event) {
84
+ [weakSelf emitOnSnaplyEvent:event];
85
+ };
86
+ SnaplyBridge.tapRelay = ^BOOL(UIView *surface, CGPoint point) {
87
+ return SnaplyRelayTap(surface, point);
88
+ };
89
+ [SnaplyBridge configureWithKey:key
90
+ host:host
91
+ userId:userId
92
+ userName:userName
93
+ collectVendorId:collectVendorId
94
+ language:language
95
+ serverKeys:serverKeys
96
+ completion:^(NSString *code, NSString *message, NSInteger status) {
97
+ if (code == nil) {
98
+ resolve(nil);
99
+ return;
100
+ }
101
+ reject(code, message, [NSError errorWithDomain:@"SnaplyAgent" code:status userInfo:@{@"status" : @(status)}]);
102
+ }];
103
+ }
104
+
105
+ - (void)identify:(NSString *)id name:(NSString *)name phone:(NSString *)phone identitySignature:(NSString *)identitySignature
106
+ {
107
+ [SnaplyBridge identifyWithId:id name:name phone:phone identitySignature:identitySignature];
108
+ }
109
+
110
+ - (void)reset
111
+ {
112
+ [SnaplyBridge reset];
113
+ }
114
+
115
+ - (void)supportCode:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
116
+ {
117
+ [SnaplyBridge supportCode:^(NSString *code) {
118
+ resolve(code ?: [NSNull null]);
119
+ }];
120
+ }
121
+
122
+ - (void)showSupportCode
123
+ {
124
+ [SnaplyBridge showSupportCode];
125
+ }
126
+
127
+ - (void)stop
128
+ {
129
+ [SnaplyBridge stop];
130
+ }
131
+
132
+ - (NSNumber *)isLiveViewActive
133
+ {
134
+ return @(SnaplyBridge.isLiveViewActive);
135
+ }
136
+
137
+ - (NSNumber *)isRemoteControlActive
138
+ {
139
+ return @(SnaplyBridge.isRemoteControlActive);
140
+ }
141
+
142
+ @end
@@ -0,0 +1,123 @@
1
+ // Copyright © 2026 iFixgroup. All rights reserved.
2
+ import Foundation
3
+ import SnaplyAgent
4
+ import UIKit
5
+
6
+ @objc(SnaplyBridge)
7
+ public final class SnaplyBridge: NSObject {
8
+ @objc public static var emit: (([String: Any]) -> Void)?
9
+ @objc public static var tapRelay: ((UIView, CGPoint) -> Bool)?
10
+
11
+ private static let host = ReactSurfaceHost()
12
+
13
+ @objc public static func configure(
14
+ key: String,
15
+ host: String?,
16
+ userId: String?,
17
+ userName: String?,
18
+ collectVendorId: Bool,
19
+ language: String,
20
+ serverKeys: [String],
21
+ completion: @escaping (String?, String?, Int) -> Void
22
+ ) {
23
+ onMain {
24
+ var environment = SnaplyEnvironment.live
25
+ if let host {
26
+ guard let url = URL(string: host) else { return completion("insecure_environment", "environment is not a URL.", 0) }
27
+ environment = .custom(url, serverKeys: serverKeys)
28
+ }
29
+ Snaply.on(callbacks)
30
+ self.host.attach()
31
+ Snaply.configure(
32
+ key: key,
33
+ environment: environment,
34
+ user: userId.map { SnaplyUser(id: $0, name: userName) },
35
+ collectVendorId: collectVendorId,
36
+ language: language
37
+ ) { error in
38
+ guard let error else { return completion(nil, nil, 0) }
39
+ let snaply = error as? SnaplyError
40
+ completion(snaply?.code ?? "error", snaply?.message ?? error.localizedDescription, snaply?.status ?? 0)
41
+ }
42
+ }
43
+ }
44
+
45
+ @objc public static func identify(id: String, name: String?, phone: String?, identitySignature: String?) {
46
+ onMain { Snaply.identify(id: id, name: name, phone: phone, identitySignature: identitySignature) }
47
+ }
48
+
49
+ @objc public static func reset() {
50
+ onMain { Snaply.reset() }
51
+ }
52
+
53
+ @objc public static func supportCode(_ completion: @escaping (String?) -> Void) {
54
+ onMain { completion(Snaply.supportCode()) }
55
+ }
56
+
57
+ @objc public static func showSupportCode() {
58
+ onMain { Snaply.showSupportCode() }
59
+ }
60
+
61
+ @objc public static func stop() {
62
+ onMain { Snaply.stop() }
63
+ }
64
+
65
+ @objc public static var isLiveViewActive: Bool { Snaply.isLiveViewActive }
66
+
67
+ @objc public static var isRemoteControlActive: Bool { Snaply.isRemoteControlActive }
68
+
69
+ private static func onMain(_ work: @escaping @MainActor () -> Void) {
70
+ DispatchQueue.main.async { MainActor.assumeIsolated { work() } }
71
+ }
72
+
73
+ private static var callbacks: SnaplyCallbacks {
74
+ SnaplyCallbacks(
75
+ onRequestShown: { send("requestShown") },
76
+ onAllowed: { capture in send("allowed", ["captureId": capture.captureId, "imageUrl": capture.imageUrl]) },
77
+ onDenied: { send("denied") },
78
+ onExpired: { send("expired") },
79
+ onError: { error in
80
+ let snaply = error as? SnaplyError
81
+ send("error", ["code": snaply?.code ?? "error", "message": snaply?.message ?? error.localizedDescription, "status": snaply?.status ?? 0])
82
+ },
83
+ onRemoteControl: { active in send("remoteControl", ["active": active]) },
84
+ onLiveEnded: { session in send("liveEnded", ["sessionId": session.sessionId]) },
85
+ onLiveView: { active in send("liveView", ["active": active]) }
86
+ )
87
+ }
88
+
89
+ private static func send(_ name: String, _ fields: [String: Any] = [:]) {
90
+ emit?(fields.merging(["name": name]) { _, new in new })
91
+ }
92
+ }
93
+
94
+ private final class ReactSurfaceHost: SnaplyHostedView {
95
+ private weak var surface: UIView?
96
+
97
+ var providesSnapshot: Bool { false }
98
+ var controlMode: SnaplyHostedControlMode { .fallback }
99
+
100
+ @MainActor
101
+ func attach() {
102
+ let root = UIApplication.shared.connectedScenes
103
+ .compactMap { $0 as? UIWindowScene }
104
+ .flatMap(\.windows)
105
+ .first(where: \.isKeyWindow)?
106
+ .rootViewController?.view
107
+ guard root !== surface else { return }
108
+ if let surface { Snaply.registerHostedView(surface, host: nil) }
109
+ surface = root
110
+ if let root { Snaply.registerHostedView(root, host: self) }
111
+ }
112
+
113
+ @MainActor
114
+ func snapshot(_ request: SnaplyHostedSnapshotRequest, completion: @escaping (SnaplyHostedSnapshot?) -> Void) {
115
+ completion(nil)
116
+ }
117
+
118
+ @MainActor
119
+ func control(_ input: SnaplyHostedInput) -> Bool {
120
+ guard input.action == .tap, let surface else { return false }
121
+ return SnaplyBridge.tapRelay?(surface, input.point) ?? false
122
+ }
123
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { type ViewProps } from 'react-native';
3
+ /** The mark the native SDKs look for in a view's `testID`. */
4
+ export declare const SNAPLY_REDACT_MARK = "snaply-redact";
5
+ /**
6
+ * Hides its children in every screenshot and live frame, and locks them for remote control. The box is
7
+ * painted on the device before the image is encoded.
8
+ */
9
+ export declare function SnaplyRedact({ children, testID, ...props }: ViewProps): React.JSX.Element;
package/lib/index.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ export { SnaplyRedact, SNAPLY_REDACT_MARK } from './SnaplyRedact';
2
+ /** A failure the SDK reports: `invalid_key`, `origin_mismatch`, `quota_exceeded`, … */
3
+ export declare class SnaplyError extends Error {
4
+ readonly code: string;
5
+ readonly status: number;
6
+ constructor(code: string, message: string, status?: number);
7
+ }
8
+ export type SnaplyUser = {
9
+ id: string;
10
+ name?: string;
11
+ };
12
+ export type SnaplyCapture = {
13
+ captureId: string;
14
+ imageUrl: string;
15
+ };
16
+ /**
17
+ * The master key of a Snaply stack running on your own machine. It is public and a secret on no machine: pass it
18
+ * in `serverKeys` only together with the address of such a stack.
19
+ */
20
+ export declare const SnaplyDevelopmentMaster = "BBfK1HoW7C4QbWBHQYk3qP3TJRqyEh9gBw4lp2tmOR3H69m_YdmU24iYVDbWZ_0uqNqKiDwtvY7OfvVpwGBcLzA";
21
+ export type SnaplyConfiguration = {
22
+ /** Console → Products → your product → API key. An iOS and an Android product each have their own. */
23
+ key: string;
24
+ /** A self-hosted host, or a backend on your own machine. Plain `http` is accepted for loopback only. */
25
+ environment?: string;
26
+ /**
27
+ * The master public keys of the server at `environment` (base64url). Everything the SDK and its server exchange
28
+ * is sealed to keys those masters vouch for; the live server's are built in, another server brings its own.
29
+ */
30
+ serverKeys?: string[];
31
+ user?: SnaplyUser;
32
+ collectVendorId?: boolean;
33
+ language?: string;
34
+ };
35
+ export type SnaplyIdentity = {
36
+ id: string;
37
+ name?: string;
38
+ /** E.164. */
39
+ phone?: string;
40
+ /** Computed on your server. */
41
+ identitySignature?: string;
42
+ };
43
+ /** What the SDK tells the app. Every callback is optional. */
44
+ export type SnaplyCallbacks = {
45
+ onRequestShown?: () => void;
46
+ onAllowed?: (capture: SnaplyCapture) => void;
47
+ onDenied?: () => void;
48
+ onExpired?: () => void;
49
+ onError?: (error: SnaplyError) => void;
50
+ /** Remote control started (`true`) after the person allowed it, or ended. */
51
+ onRemoteControl?: (active: boolean) => void;
52
+ /** Live view stopped; the argument is the session's id. */
53
+ onLiveEnded?: (sessionId: string) => void;
54
+ /**
55
+ * Live view started (`true`), once the sharing indicator is on screen, or ended. At the end it comes after
56
+ * `onRemoteControl(false)` and before `onLiveEnded`.
57
+ */
58
+ onLiveView?: (active: boolean) => void;
59
+ };
60
+ declare const methods: {
61
+ /** Registers this device and connects. */
62
+ configure(configuration: SnaplyConfiguration): Promise<void>;
63
+ /** Observe SDK events. Attach before `configure`: a request can arrive as soon as the device registers. */
64
+ on(next: SnaplyCallbacks): void;
65
+ /** Attaches the signed-in person. */
66
+ identify(identity: SnaplyIdentity): void;
67
+ /** Detaches the person, on sign-out. The device keeps its support code. */
68
+ reset(): void;
69
+ /** The code an anonymous caller reads to the agent. */
70
+ supportCode(): Promise<string | null>;
71
+ /** Shows the support code in the SDK's own sheet. */
72
+ showSupportCode(): void;
73
+ /** Disconnects and removes any visible prompt. */
74
+ stop(): void;
75
+ };
76
+ type SnaplyAnswers = {
77
+ /**
78
+ * True while the person is sharing this app's screen with support: from their "Start sharing" until the live
79
+ * view has ended. For anything your app would rather not show or do while support watches.
80
+ */
81
+ readonly isLiveViewActive: boolean;
82
+ /** True while support is controlling the app. Never true outside a live view. */
83
+ readonly isRemoteControlActive: boolean;
84
+ };
85
+ /** Snaply Agent. Call `configure` once at app start; nothing else is needed for captures to work. */
86
+ export declare const Snaply: typeof methods & SnaplyAnswers;
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var N=(W,c)=>{for(var x in c)p(W,x,{get:c[x],enumerable:!0})},L=(W,c,x,d)=>{if(c&&typeof c=="object"||typeof c=="function")for(let e of j(c))!y.call(W,e)&&e!==x&&p(W,e,{get:()=>c[e],enumerable:!(d=g(c,e))||d.enumerable});return W};var M=W=>L(p({},"__esModule",{value:!0}),W);var z={};N(z,{SNAPLY_REDACT_MARK:()=>h,Snaply:()=>Z,SnaplyDevelopmentMaster:()=>D,SnaplyError:()=>P,SnaplyRedact:()=>B});module.exports=M(z);var q=require("react-native"),G=require("react-native"),w=require("react/jsx-runtime");(function(W,c){function x(t,k){return u(k- -117,t)}function d(t,k){return u(t-918,k)}for(var e=W();;)try{var o=parseInt(d(1067,"XIfR"))/1*(-parseInt(x(")UzL",85))/2)+-parseInt(d(1159,"ej$@"))/3*(parseInt(d(1083,"E@&4"))/4)+-parseInt(d(1171,"Zmp5"))/5+-parseInt(x("hcMi",97))/6*(-parseInt(x("wHVW",114))/7)+parseInt(x("3[)j",27))/8*(parseInt(d(1131,"kztY"))/9)+parseInt(x("5SIu",8))/10+parseInt(d(1123,")UzL"))/11*(parseInt(d(1169,"d4h#"))/12);if(o===c)break;e.push(e.shift())}catch{e.push(e.shift())}})(l,4099*-49+-16698+626045);var K=Object[n(579,"F%3R")],F=(W,c,x)=>c in W?K(W,c,{[f(-751,"Aekr")]:!0,[f(-790,"F%3R")]:!0,[n(664,"hcMi")]:!0,[f(-719,"EXjs")]:x}):W[c]=x,v=(W,c,x)=>F(W,typeof c!==f(-820,"NCvj")?c+"":c,x);function f(W,c){return u(W- -967,c)}var s=q.TurboModuleRegistry[n(700,"giQH")](n(583,"eU[W")),h=f(-835,"5SIu");function B({[f(-828,"AB^0")]:W,[n(638,"r)h!")]:c,...x}){function d(o,t){return n(o- -379,t)}function e(o,t){return n(t- -41,o)}return(0,w.jsx)(G.View,{...x,[e("HTc5",573)]:!1,[d(243,"ej$@")]:c?""[d(333,"]3n5")](h,"-")[d(251,"XIfR")](c):h,[e("7q7)",637)]:W})}function l(){var W=["WRBdISkmmua","aMLPpfRdSxBcMSkjkMBdRgzHWPtdMgtcV8o4wfu","sSkAW4ufWOu","wx8mzSktCGuwWOLipW","B0jDBmonmCotDSkqWPNcJ8ktWPO","DhVdJCoXgJ0jWOj2WOddHa","WRddQmkvW7tcNXVdPSoNw8opW5u","kSoyx8k5w0xdGfVdOGG","W5P0W7xdOmoaWQxcSgRcTmoJW7ldJCoYfSoJWPO","WPpcQSkqfSkfqMa","smoAWOHIWPNdMwDgW5Sh","ywpdSLCqWRVdNG","iIyGACkRW5pdQmktWOe2WReFWOvLdSks","W5bVW5ddPCosWRlcG20","vmoZWQqMWRy","amkWW6rTxJS","EatdRSkHm8kHbSoGW7G","zmorWRqb","sgJdU1eN","rCo+WPSAEvddM8oDl8ouWOTZW5e","lSovxSk9sfi","BG/cGfRdTSkcW4fIwG8","wh0ofmo9vZ8VWO0","xJGlAXL3W7O1W5iS","WPRdOaJdVYyu","zxxdK0eCWRpdJYldICkcWPrWWPKQWOyduI4Sdci","W4KdpCkNs8o7ESo5ACoJW4ZcSSo7WOFcSW","f8kGW7P0vc3dG1BcS2eF","zmoFWQaqWQtdMWWxva","iCoxr8kX","qvb7","WPPAW6/dMmou","W6dcSCovWQtcLYBdNCogrSoa","WOnuwLhcNCoUjr9+ebfZWO4","aL3dVSkil8kDad8fW60","nv7cJSk2sHb3e8oaWPjBWRG","fqC6WOK7af1wF8oIWRLSaq","cSoHqCk6xa","W4arcbO","eSk0W6zXxG","lCo+WO5dW5C","WRbmW43dOmoS","wsicA0BdJMxcHSkgka","W7BcNqPkpmktWOlcSSoiW5lcPa","WRauW65WWRxcKbm0sgZcNJei","W6XiWOKLW6ddJ1CFFLFcHH8kW60D","WONdUxCfW4i3","eLFdOSkDk8kB","AX5bgYO","WQjJt8k/W6naDSkMwa","esS5m2GJtNxcGK7cLW","WQxdH8k7gvVcP8kbWP8SqJ7cKr/dMa","ESkiW4ZdLq","W705WPTVWROrW64glmozCrxcKa","DmokWReqWQtdMG","n8kklCoEsmkFW65HluDI","WQjIW40XW6X2WQW/","bsz5lCoBscqJWP4","arddINJcSa","W6bkW43dI8or","WRHHW40MW6vAW7mHpSoSxIFcQG","iJ7cJ8kTua","cmknoSolyCkiW4TJla","WQJdHSk4hKhcQ8k3WPq","cmkyW41CFq","WQ3dTSofW4NdSrbV","W6bjWR8L","W5ykbatdISkUCcq","WONcT8kWfG","gSkIi8kFW50","W4iqp8okWPxcNfClnq","dHZdOu3cNmkDaSkf","WPdcGWRdVmolW4DQla","W5vqWRhdI8kK","EatdO8kKkCkRnmoRW7JdPSk6","WPNcKSkacwNdOq","BCkQW5eHW4yTzCkAW5WHoXNdGSoRhZHhW5lcNmoyWOddVK/dQCozWOldSSk3gxpdLSkvW57dMSokfmo0BSoXpbFcGSoFWQiLWORcTSkVkgnRb8kGW7DZW70bW5VdRSk+lSoHW75iEJddGCklWQaLvmkblCofDrhdHSkKW5z3WOWOW6pcScPFAa","W4JdTCoJxmopg33cLwldKqBcGq","jcpcKCkUrW0UWOrGWPVdLvxcImkbWQm","mLZdKW3dUmk5W6bxCqCKWPn6xeCQwW","W4ywaHG","rCoZWRfzWOy","jcpcMCkN","bLddNCk/pW","WRVdP8koW7G","WQ7dJmkohLtcSSk9WPqgrd7cJr8","zmorWRWiWRddMrO/uHz7","r1LJW5z0vqK","DSoWz8o4WQC","eXi2FCo5iNSg","WPVcOCkH","WQRcHmkjW7qY","ggPxmem","omokWPxcLwRdQSosmmklW5a","WQhdO8kqW6NcPda","yWq7sIu","W7uZcCoZWQ4eFmkcvCoXivm","fau+WO83b1PGw8oGWObxgq","W5Omkq3dGmk1Cc4","eCo+WRHIW5qYW40X","frtdS0/cJq","W7NdPYFdISo6","WP/cQ8k7b8kwwq","CCkXW5RdIKi","f8krpmoEs8kuW5Tfj01Z","WQldJCkZfLZcPCkKWP8IudFcHG","k8o0WRX8W4WIW646y0Sc","WOxdU8kzpge","WQldJCkZfLZcPCkKWP8M","BmoBWQK","WRZdQ8ogW5tdIJe","wcX0jSoJrtm","W5z0WPmQW7G","wSkBW5iyWR4lBmkI","WOddPYxdOIucWRBdUerLkMFdKHpdHre","FSkahmoKr2/dH0hdHdK","bszUmmoAvdm1WO5UiSoXbfS","WO7cOCkKeCksxMBcQ2pdRYFcIG","dZPooSoz","DhT/mSk0W6BdN8kyWQiR","W4VcU34lW58jW50g","tSklW4mdWOea","W5yMfCkixG","WRldLSk8bedcSq","o8k+k8kfW7K","FvqunSkzaXfDxq","W5z6WQtdJmkPWRldHa","WQ1MW5JdP8oPW6RdQSoOW7O","WRNdP8knW7RcMbxdR8oV","W5XPW7xdOmoaWQxcSgRcTmoJ","W7nMD8k4W55wDG","yMFdRee","i1n2due","W7uWcCoYWQDcz8kEv8orbG","ESkuW4ZdKKddH8oeomkUW7zgW6LbqCkU","WQBdR8oyW4u","md7cLmk2qWW2WRC"];return l=function(){return W},l()}var P=class extends Error{constructor(W,c,x=710*2+1957+-3377){var d={rtAWj:k(-87,"ZSg@"),URHju:function(i,S,a){return i(S,a)},faJRI:function(i,S,a){return i(S,a)},UdSOw:k(-55,"hcMi")};function e(i,S){return n(S- -78,i)}var o=d[k(-49,"wLS!")][e("d4h#",542)]("|"),t=1*7415+828+8243*-1;function k(i,S){return n(i- -665,S)}for(;;){switch(o[t++]){case"0":this[k(-71,"Zmp5")]=W;continue;case"1":this[k(-6,"yp0t")]=k(-31,"N$l@");continue;case"2":super(c);continue;case"3":this[e("PA1A",633)]=x;continue;case"4":d[k(-25,"Zmp5")](v,this,k(-83,"HTc5"));continue;case"5":d[e("xsaD",508)](v,this,d[e("N$l@",627)]);continue}break}}},D=n(604,"jaW!"),m={},Q=!1;function H(){if(Q)return;function W(c,x){return f(c-1503,x)}Q=!0,s[W(693,"F%3R")](V)}function V(W){var c={};c[d(385,"*Q)r")]=x(-695,"XIfR");function x(t,k){return f(t-83,k)}c[d(458,"o49w")]=d(377,"4@IG"),c[x(-657,"yp0t")]=d(442,"EXjs"),c[d(412,"6jkT")]=x(-747,"r)h!");function d(t,k){return f(t-1185,k)}c[x(-634,"o49w")]=d(408,"wHVW"),c[d(427,"F%3R")]=d(352,"eU[W"),c[d(349,"7q7)")]=d(379,"aMDO"),c[d(475,"ZSg@")]=function(t,k){return t===k};var e=c;switch(W[x(-728,"ej$@")]){case e[x(-711,"3[)j")]:m[d(406,"wHVW")]?.();break;case e[x(-705,"F%3R")]:var o={};o[d(339,")UzL")]=W[d(455,"HTc5")]??"",o[d(361,"xsaD")]=W[x(-756,"5SIu")]??"",m[x(-659,"OeUO")]?.(o);break;case e[d(359,"6)b4")]:m[d(388,"AB^0")]?.();break;case e[x(-748,"EXjs")]:m[x(-755,"wHVW")]?.();break;case e[x(-739,"68KA")]:m[x(-666,"XIfR")]?.(new P(W[d(372,"hcMi")]??x(-673,"jaW!"),W[x(-664,"yp0t")]??"",W[x(-689,"F%3R")]??-900+18*349+-5382));break;case d(446,"B&O7"):m[x(-630,"Zmp5")]?.(W[d(447,"Aekr")]===!0);break;case e[x(-729,"]3n5")]:m[d(364,"OeUO")]?.(W[d(417,"o49w")]??"");break;case e[x(-661,"HTc5")]:m[x(-683,"7q7)")]?.(e[d(422,"d4h#")](W[x(-691,"jaW!")],!0));break}}function u(W,c){W=W-121;var x=l(),d=x[W];if(u.BUbCkp===void 0){var e=function(i){for(var S="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",a="",b="",R=0,C,r,O=0;r=i.charAt(O++);~r&&(C=R%4?C*64+r:r,R++%4)?a+=String.fromCharCode(255&C>>(-2*R&6)):0)r=S.indexOf(r);for(var I=0,J=a.length;I<J;I++)b+="%"+("00"+a.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(b)},o=function(i,S){var a=[],b=0,R,C="";i=e(i);var r;for(r=0;r<256;r++)a[r]=r;for(r=0;r<256;r++)b=(b+a[r]+S.charCodeAt(r%S.length))%256,R=a[r],a[r]=a[b],a[b]=R;r=0,b=0;for(var O=0;O<i.length;O++)r=(r+1)%256,b=(b+a[r])%256,R=a[r],a[r]=a[b],a[b]=R,C+=String.fromCharCode(i.charCodeAt(O)^a[(a[r]+a[b])%256]);return C};u.ekWmrk=o,u.beIoyi={},u.BUbCkp=!0}var t=x[-4972+-1*-5231+-259];u.UNnddA!==t&&(u.beIoyi={},u.UNnddA=t);var k=u.beIoyi[W];return k===void 0?(u.RIDtsg===void 0&&(u.RIDtsg=!0),d=u.ekWmrk(d,c),u.beIoyi[W]=d):d=k,d}function n(W,c){return u(W-456,c)}var X={async[n(598,"A!ZI")](W){function c(e,o){return f(o-1456,e)}function x(e,o){return f(o-642,e)}var d={xMyoQ:function(e){return e()},hGLVz:c("hcMi",622)};d[x("E@&4",-150)](H);try{await s[x("F%3R",-145)](W[x("HTc5",-144)],W[x("ej$@",-110)]??null,W[x("AB^0",-78)]?.id??null,W[x("XIfR",-185)]?.[x("Aekr",-87)]??null,W[c("hcMi",639)]??!0,W[c("ej$@",689)]??"en",W[c("]3n5",732)]??[])}catch(e){let o=e;throw new P(o[c("HTc5",715)]??x("6)b4",-129),o[c("68KA",687)]??d[c("mfxV",642)],o[c("jaW!",674)]?.[x("xhuH",-92)]??2*-3106+6*-903+11630*1)}},on(W){var c={EWknb:function(d){return d()}};m=W;function x(d,e){return f(e-591,d)}c[x("Aekr",-130)](H)},[f(-796,"N$l@")](W){function c(d,e){return n(d- -399,e)}function x(d,e){return n(d- -978,e)}s[x(-387,"F%3R")](W.id,W[x(-315,"r)h!")]??null,W[c(220,"fP]U")]??null,W[x(-371,"IKTm")]??null)},[f(-795,"xsaD")](){function W(c,x){return f(x-1471,c)}s[W("xsaD",676)]()},[n(692,"EXjs")](){function W(c,x){return n(c- -25,x)}return s[W(607,"eU[W")]()},[f(-732,"6jkT")](){function W(c,x){return n(c- -1356,x)}s[W(-694,"E@&4")]()},[f(-843,"E@&4")](){function W(c,x){return n(x- -1132,c)}s[W("AB^0",-524)]()}},Z=Object[n(677,"3ypI")](X,{[n(673,"7q7)")]:{[f(-748,"mfxV")]:!0,[f(-728,"4@IG")]:()=>s[n(642,"xhuH")]()},[n(690,"yp0t")]:{[n(688,"*Q)r")]:!0,[n(618,"XIfR")]:()=>s[n(666,"d4h#")]()}});
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@snaplyagent/react-native",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Snaply Agent for React Native — consent-first screen capture for support teams: screenshots, live view and remote control, with on-device redaction.",
5
+ "main": "lib/index.js",
6
+ "react-native": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "files": [
9
+ "lib",
10
+ "spec",
11
+ "android",
12
+ "ios",
13
+ "SnaplyAgentReactNative.podspec",
14
+ "LICENSE",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "keywords": [
18
+ "react-native",
19
+ "ios",
20
+ "android",
21
+ "snaply",
22
+ "support",
23
+ "screen-sharing",
24
+ "cobrowsing"
25
+ ],
26
+ "homepage": "https://snaplyagent.com/docs",
27
+ "license": "SEE LICENSE IN LICENSE",
28
+ "peerDependencies": {
29
+ "react": "*",
30
+ "react-native": ">=0.88.0"
31
+ },
32
+ "codegenConfig": {
33
+ "name": "SnaplyAgentSpec",
34
+ "type": "modules",
35
+ "jsSrcsDir": "spec",
36
+ "android": {
37
+ "javaPackageName": "com.snaplyagent.reactnative"
38
+ },
39
+ "ios": {
40
+ "modulesProvider": {
41
+ "SnaplyAgent": "SnaplyAgentModule"
42
+ }
43
+ }
44
+ }
45
+ }