@doorstepai/dropoff-sdk 2.1.2 → 2.2.2
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/CHANGELOG.md +66 -0
- package/README.md +308 -41
- package/android/build.gradle +5 -1
- package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +566 -2
- package/ios/DoorstepAI.mm +12 -2
- package/ios/DoorstepAI.swift +151 -2
- package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +10582 -5745
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3833 -2687
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +10582 -5745
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +10582 -5745
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +95 -4
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3833 -2687
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +3802 -2674
- package/lib/module/DoorstepAI.js +425 -12
- package/lib/module/DoorstepAI.js.map +1 -1
- package/lib/module/RootDoorstepAI.js +88 -26
- package/lib/module/RootDoorstepAI.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/DoorstepAI.d.ts +349 -7
- package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
- package/lib/typescript/src/RootDoorstepAI.d.ts +31 -3
- package/lib/typescript/src/RootDoorstepAI.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/DoorstepAI.tsx +575 -23
- package/src/RootDoorstepAI.tsx +130 -47
- package/src/index.tsx +10 -0
package/ios/DoorstepAI.swift
CHANGED
|
@@ -2,6 +2,13 @@ import Foundation
|
|
|
2
2
|
import React
|
|
3
3
|
import DoorstepDropoffSDK
|
|
4
4
|
|
|
5
|
+
// Deliberately does NOT import CoreBluetooth / CoreLocation / CoreMotion. This
|
|
6
|
+
// bridge reads no permission state of its own — the SDK's PermissionEngine owns
|
|
7
|
+
// every status read and every prompt — and not importing the frameworks is the
|
|
8
|
+
// cheapest guarantee that a future edit cannot casually instantiate a
|
|
9
|
+
// `CBCentralManager` (which prompts, and aborts a host with no
|
|
10
|
+
// NSBluetoothAlwaysUsageDescription) or a second `CLLocationManager`.
|
|
11
|
+
|
|
5
12
|
@objc(DoorstepAI)
|
|
6
13
|
class DoorstepAIBridge: RCTEventEmitter {
|
|
7
14
|
@objc
|
|
@@ -61,8 +68,150 @@ class DoorstepAIBridge: RCTEventEmitter {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
@objc
|
|
64
|
-
func
|
|
65
|
-
DoorstepAI.
|
|
71
|
+
func setDoorstepGoApiKey(_ apiKey: String) {
|
|
72
|
+
DoorstepAI.setDoorstepGoApiKey(key: apiKey)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@objc
|
|
76
|
+
func debugStateJson(_ resolve: @escaping RCTPromiseResolveBlock,
|
|
77
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
78
|
+
resolve(DoorstepAI.debugStateJson())
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// MARK: - Permissions
|
|
82
|
+
//
|
|
83
|
+
// Pass-throughs to the SDK's whitelist permission API. The SDK owns the
|
|
84
|
+
// buckets, the eight-state vocabulary, the prompt order and the "what will I
|
|
85
|
+
// decline to ask, and why" planning; this file only translates names across the
|
|
86
|
+
// bridge. What USED to live here — a hand-rolled CLLocationManager /
|
|
87
|
+
// CMMotionActivityManager / CBManager reader plus a 0.25 s polling loop to
|
|
88
|
+
// guess when a prompt had been answered — was a second implementation of the
|
|
89
|
+
// same policy, and a second implementation is a second set of states to drift
|
|
90
|
+
// apart. `PermissionEngine` already sequences one prompt at a time, awaits each
|
|
91
|
+
// answer against its PRE-prompt state, refuses to interleave two request
|
|
92
|
+
// sequences, and honours the caller's timeout.
|
|
93
|
+
//
|
|
94
|
+
// The one rule this file must still respect: never instantiate a
|
|
95
|
+
// `CBCentralManager`. Doing so PROMPTS, and it hard-crashes a host with no
|
|
96
|
+
// `NSBluetoothAlwaysUsageDescription`. Bluetooth state is read by the SDK from
|
|
97
|
+
// the static `CBManager.authorization`.
|
|
98
|
+
|
|
99
|
+
/// Legacy three-key view of the eight-state buckets, so hosts written against
|
|
100
|
+
/// the published 2.x wrapper API keep working. `location` is the When-In-Use
|
|
101
|
+
/// bucket (an Always-vs-When-In-Use distinction cannot survive three values —
|
|
102
|
+
/// that is what `statuses.locationAlways` is for).
|
|
103
|
+
private static func legacyPermissionsView(
|
|
104
|
+
_ statuses: [DoorstepPermission: DoorstepPermissionStatus]
|
|
105
|
+
) -> [String: String] {
|
|
106
|
+
func collapse(_ permission: DoorstepPermission) -> String {
|
|
107
|
+
guard let state = statuses[permission]?.state else { return "prompt" }
|
|
108
|
+
switch state {
|
|
109
|
+
case .granted, .whenInUseOnly, .unavailable: return "granted"
|
|
110
|
+
case .notDetermined: return "prompt"
|
|
111
|
+
case .denied, .permanentlyDenied, .restricted, .notDeclared: return "denied"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
"location": collapse(.locationWhenInUse),
|
|
116
|
+
"motion": collapse(.motionFitness),
|
|
117
|
+
"bluetooth": collapse(.bluetooth),
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private static func serialize(
|
|
122
|
+
_ statuses: [DoorstepPermission: DoorstepPermissionStatus]
|
|
123
|
+
) -> [String: Any] {
|
|
124
|
+
var out: [String: Any] = [:]
|
|
125
|
+
for (permission, status) in statuses {
|
|
126
|
+
out[permission.rawValue] = [
|
|
127
|
+
"permission": permission.rawValue,
|
|
128
|
+
"state": status.state.rawValue,
|
|
129
|
+
"osStatus": status.osStatus,
|
|
130
|
+
"canRequest": status.canRequest,
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
return out
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/// `nil` / an absent array means "no whitelist" — every bucket. An EMPTY array
|
|
137
|
+
/// is not the same thing and must stay empty: it means the caller narrowed the
|
|
138
|
+
/// whitelist down to nothing this platform has, and turning that into "ask for
|
|
139
|
+
/// everything" would be the opposite of what they asked for.
|
|
140
|
+
private static func parseWhitelist(_ raw: Any?) -> [DoorstepPermission] {
|
|
141
|
+
guard let names = raw as? [String] else { return DoorstepPermission.all }
|
|
142
|
+
return names.compactMap { DoorstepPermission.from(wireName: $0) }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private static func statusPayload(
|
|
146
|
+
_ statuses: [DoorstepPermission: DoorstepPermissionStatus]
|
|
147
|
+
) -> [String: Any] {
|
|
148
|
+
return [
|
|
149
|
+
"statuses": serialize(statuses),
|
|
150
|
+
"permissions": legacyPermissionsView(statuses),
|
|
151
|
+
"unsupported": [String](),
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@objc
|
|
156
|
+
func checkPermissions(_ permissions: NSArray?,
|
|
157
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
158
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
159
|
+
// Main queue: `checkPermissions` is @MainActor (CLLocationManager is
|
|
160
|
+
// main-thread affine), and @ReactMethod bodies run off the main thread.
|
|
161
|
+
DispatchQueue.main.async {
|
|
162
|
+
let whitelist = DoorstepAIBridge.parseWhitelist(permissions)
|
|
163
|
+
resolve(DoorstepAIBridge.statusPayload(DoorstepAI.checkPermissions(whitelist)))
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@objc
|
|
168
|
+
func checkPermissionsJson(_ permissions: NSArray?,
|
|
169
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
170
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
171
|
+
DispatchQueue.main.async {
|
|
172
|
+
let whitelist = DoorstepAIBridge.parseWhitelist(permissions)
|
|
173
|
+
resolve(DoorstepAI.checkPermissionsJson(whitelist))
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/// iOS half of the cross-platform requester.
|
|
178
|
+
///
|
|
179
|
+
/// `options.permissions` is the whitelist and it is honoured exactly: absent
|
|
180
|
+
/// (or null) requests every bucket, an array requests only those buckets.
|
|
181
|
+
/// `onlyIfNotDetermined` and `timeoutSeconds` are left at the SDK's defaults
|
|
182
|
+
/// when not supplied — `onlyIfNotDetermined: true` especially, because it is
|
|
183
|
+
/// what stops a launch-time call from re-escalating a user's deliberate
|
|
184
|
+
/// "While Using the App" choice (FP2 7a).
|
|
185
|
+
///
|
|
186
|
+
/// Resolves once the SDK's completion fires, which is after the prompt sequence
|
|
187
|
+
/// has settled — including the in-flight refusal, which comes back as every
|
|
188
|
+
/// bucket `deferred` rather than as a hung promise.
|
|
189
|
+
@objc
|
|
190
|
+
func requestPermissions(_ options: NSDictionary?,
|
|
191
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
192
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
193
|
+
let whitelist = DoorstepAIBridge.parseWhitelist(options?["permissions"])
|
|
194
|
+
let onlyIfNotDetermined = (options?["onlyIfNotDetermined"] as? NSNumber)?.boolValue ?? true
|
|
195
|
+
let timeout = (options?["timeoutSeconds"] as? NSNumber)?.doubleValue ?? 120
|
|
196
|
+
DispatchQueue.main.async {
|
|
197
|
+
DoorstepAI.requestPermissions(
|
|
198
|
+
whitelist,
|
|
199
|
+
onlyIfNotDetermined: onlyIfNotDetermined,
|
|
200
|
+
timeout: timeout
|
|
201
|
+
) { result in
|
|
202
|
+
var payload = DoorstepAIBridge.statusPayload(result.statuses)
|
|
203
|
+
payload["requested"] = result.requested.map { $0.rawValue }
|
|
204
|
+
payload["alreadyDetermined"] = result.alreadyDetermined.map { $0.rawValue }
|
|
205
|
+
payload["unavailable"] = result.unavailable.map { $0.rawValue }
|
|
206
|
+
payload["didRequest"] = result.didRequest
|
|
207
|
+
var deferred: [String: String] = [:]
|
|
208
|
+
for (permission, reason) in result.deferred {
|
|
209
|
+
deferred[permission.rawValue] = reason
|
|
210
|
+
}
|
|
211
|
+
payload["deferred"] = deferred
|
|
212
|
+
resolve(payload)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
66
215
|
}
|
|
67
216
|
|
|
68
217
|
@objc
|
|
@@ -10,18 +10,15 @@
|
|
|
10
10
|
<key>DebugSymbolsPath</key>
|
|
11
11
|
<string>dSYMs</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>ios-
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
14
|
<key>LibraryPath</key>
|
|
15
15
|
<string>DoorstepDropoffSDK.framework</string>
|
|
16
16
|
<key>SupportedArchitectures</key>
|
|
17
17
|
<array>
|
|
18
18
|
<string>arm64</string>
|
|
19
|
-
<string>x86_64</string>
|
|
20
19
|
</array>
|
|
21
20
|
<key>SupportedPlatform</key>
|
|
22
21
|
<string>ios</string>
|
|
23
|
-
<key>SupportedPlatformVariant</key>
|
|
24
|
-
<string>simulator</string>
|
|
25
22
|
</dict>
|
|
26
23
|
<dict>
|
|
27
24
|
<key>BinaryPath</key>
|
|
@@ -29,15 +26,18 @@
|
|
|
29
26
|
<key>DebugSymbolsPath</key>
|
|
30
27
|
<string>dSYMs</string>
|
|
31
28
|
<key>LibraryIdentifier</key>
|
|
32
|
-
<string>ios-
|
|
29
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
33
30
|
<key>LibraryPath</key>
|
|
34
31
|
<string>DoorstepDropoffSDK.framework</string>
|
|
35
32
|
<key>SupportedArchitectures</key>
|
|
36
33
|
<array>
|
|
37
34
|
<string>arm64</string>
|
|
35
|
+
<string>x86_64</string>
|
|
38
36
|
</array>
|
|
39
37
|
<key>SupportedPlatform</key>
|
|
40
38
|
<string>ios</string>
|
|
39
|
+
<key>SupportedPlatformVariant</key>
|
|
40
|
+
<string>simulator</string>
|
|
41
41
|
</dict>
|
|
42
42
|
</array>
|
|
43
43
|
<key>CFBundlePackageType</key>
|