@doorstepai/dropoff-sdk 2.1.1 → 2.2.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 (43) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +115 -3
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +332 -0
  5. package/ios/DoorstepAI.mm +5 -2
  6. package/ios/DoorstepAI.swift +170 -2
  7. package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
  8. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  9. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +1380 -412
  10. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +13 -4
  11. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  12. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +13 -4
  13. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
  14. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  15. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3248 -2675
  16. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  17. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1380 -412
  18. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +13 -4
  19. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  20. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +13 -4
  21. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1380 -412
  22. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +13 -4
  23. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  24. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +13 -4
  25. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
  26. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  27. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3248 -2675
  28. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +3233 -2662
  29. package/lib/module/DoorstepAI.js +190 -12
  30. package/lib/module/DoorstepAI.js.map +1 -1
  31. package/lib/module/RootDoorstepAI.js +70 -26
  32. package/lib/module/RootDoorstepAI.js.map +1 -1
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/typescript/src/DoorstepAI.d.ts +151 -7
  35. package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
  36. package/lib/typescript/src/RootDoorstepAI.d.ts +13 -2
  37. package/lib/typescript/src/RootDoorstepAI.d.ts.map +1 -1
  38. package/lib/typescript/src/index.d.ts +1 -1
  39. package/lib/typescript/src/index.d.ts.map +1 -1
  40. package/package.json +2 -1
  41. package/src/DoorstepAI.tsx +241 -23
  42. package/src/RootDoorstepAI.tsx +98 -45
  43. package/src/index.tsx +4 -0
@@ -53,8 +53,12 @@ type GeofenceSessionEvent = {
53
53
  type StartDeliveryOptions = {
54
54
  /**
55
55
  * Hard upper bound on the delivery's tracking session in seconds. When the
56
- * timer fires the SDK calls `stopDelivery` automatically. Defaults to 7200
57
- * (2 hours) when not provided.
56
+ * timer fires the SDK calls `stopDelivery` automatically.
57
+ *
58
+ * Omit it for NO backstop — that is the native behaviour on both platforms.
59
+ * This wrapper used to substitute 3600 s here, which silently force-stopped
60
+ * every delivery at one hour and re-created a bug the native SDK had already
61
+ * removed. It now passes your value through untouched.
58
62
  */
59
63
  timeoutSeconds?: number;
60
64
  /**
@@ -81,6 +85,46 @@ type StartDeliveryOptions = {
81
85
  */
82
86
  driverId?: string;
83
87
  };
88
+ /**
89
+ * The grant state of one permission, as the published wrapper API has always
90
+ * spelled it. `'prompt'` means "not determined yet — asking will show a dialog".
91
+ */
92
+ type PermissionState = 'granted' | 'denied' | 'prompt';
93
+ /**
94
+ * The permission domains the SDK uses, on BOTH platforms.
95
+ *
96
+ * - `location` — CoreLocation (iOS) / `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION` (Android).
97
+ * - `motion` — Motion & Fitness (iOS) / activity recognition (Android).
98
+ * - `bluetooth`— Bluetooth (iOS) / the "Nearby devices" group (Android 12+).
99
+ *
100
+ * The string `'activity'` is still ACCEPTED wherever a `DoorstepPermissionType`
101
+ * is passed, as a **deprecated alias for `'motion'`** — it was the published name
102
+ * in `@doorstepai/dropoff-sdk-capacitor` 1.0.4 and dropping it would break hosts.
103
+ * It is normalised to `'motion'` before it reaches native, and it is never a key
104
+ * of {@link PermissionStatus}.
105
+ */
106
+ type DoorstepPermissionType = 'location' | 'motion' | 'bluetooth';
107
+ /** The state of every permission domain the SDK uses. */
108
+ interface PermissionStatus {
109
+ permissions: Record<DoorstepPermissionType, PermissionState>;
110
+ }
111
+ /** Options for {@link DoorstepAIModule.requestPermissions}. */
112
+ interface PermissionRequestOptions {
113
+ /**
114
+ * If omitted, requests everything the native SDK asks for.
115
+ *
116
+ * **This array can only narrow Bluetooth.** Both natives request their whole
117
+ * required set behind a single `includeBluetooth` / `requestBluetooth` flag —
118
+ * neither exposes per-permission selection — so the array is read as
119
+ * `includeBluetooth = permissions.includes('bluetooth')` and `location` and
120
+ * `motion` always ride the base set. Passing `['bluetooth']` alone therefore
121
+ * still requests the base set as well. Documented rather than silently
122
+ * swallowed: an array the wrapper cannot honour would be a lie.
123
+ *
124
+ * `'activity'` is accepted as a deprecated alias for `'motion'`.
125
+ */
126
+ permissions?: Array<DoorstepPermissionType | 'activity'>;
127
+ }
84
128
  /**
85
129
  * Mirrors the iOS SDK's `SDKLogLevel` enum. Only used by
86
130
  * `configureRemoteLogging` (iOS only).
@@ -91,11 +135,111 @@ declare class DoorstepAIModule {
91
135
  static init(notificationTitle?: string, notificationText?: string): Promise<void>;
92
136
  static setApiKey(apiKey: string): void;
93
137
  /**
94
- * Triggers iOS Motion/Fitness + Location permission prompts up-front so the
95
- * host app does not need to manage them itself. No-op on Android — use
96
- * `PermissionsAndroid` (already wired into `RootDoorstepAI`).
138
+ * The dangerous runtime permissions the native SDK needs on THIS device,
139
+ * version-gated. **Android only.**
140
+ *
141
+ * Foreground set only — it deliberately excludes `ACCESS_BACKGROUND_LOCATION`,
142
+ * which Android 11+ requires be requested separately and only after foreground
143
+ * location is granted (see `requestBackgroundLocationPermission`).
144
+ *
145
+ * Feed it to your own permission UI (e.g. `PermissionsAndroid.requestMultiple`)
146
+ * when you want the grant results in JS — it is the same list `requestPermissions`
147
+ * asks for, so the two cannot diverge.
148
+ *
149
+ * @param includeBluetooth include `BLUETOOTH_SCAN` (Android 12+) and
150
+ * `NEARBY_WIFI_DEVICES` (Android 13+). Native default: `true`.
151
+ */
152
+ static getRequiredPermissions(includeBluetooth?: boolean): Promise<string[]>;
153
+ /**
154
+ * True when every foreground permission the SDK needs is currently granted.
155
+ * **Android only.**
156
+ *
157
+ * @param includeBluetooth native default here is `false`, unlike the request
158
+ * methods — Bluetooth is optional, so a denied "Nearby devices" grant must not
159
+ * make the SDK look unusable.
160
+ */
161
+ static hasRequiredPermissions(includeBluetooth?: boolean): Promise<boolean>;
162
+ /**
163
+ * True when `ACCESS_BACKGROUND_LOCATION` is granted (always true below API 29,
164
+ * where it is not a separate grant). **Android only.**
165
+ */
166
+ static hasBackgroundLocationPermission(): Promise<boolean>;
167
+ /**
168
+ * The current grant state of every permission domain the SDK uses, on both
169
+ * platforms. Pure observation — it reads the platform's own status APIs
170
+ * (`CLLocationManager.authorizationStatus` / `CMMotionActivityManager.
171
+ * authorizationStatus()` / `CBManager.authorization` on iOS,
172
+ * `ContextCompat.checkSelfPermission` on Android) and shows no dialog.
173
+ *
174
+ * The set of permissions read comes from the native SDK
175
+ * (`DoorstepAI.getRequiredPermissions()` on Android); the wrapper keeps no
176
+ * permission list of its own, it only reports the state of what native names.
177
+ *
178
+ * A domain the native SDK requires no runtime grant for on this OS version
179
+ * reports `'granted'` — e.g. `motion` on Android, where sensor collection needs
180
+ * no runtime permission, and `bluetooth` below Android 12.
181
+ */
182
+ static checkPermissions(): Promise<PermissionStatus>;
183
+ /**
184
+ * The one permission requester. Asks for every runtime permission the SDK needs
185
+ * on whichever platform the app is running: Android's foreground runtime
186
+ * permissions (`DoorstepAI.requestPermissions(activity, requestCode,
187
+ * includeBluetooth)`, only the not-yet-granted ones) and iOS's Location +
188
+ * Motion/Fitness + Bluetooth prompts
189
+ * (`DoorstepAI.requestAllPermissions(requestAlwaysLocation:requestBluetooth:onlyIfNotDetermined:)`).
190
+ *
191
+ * Hosts must not branch on `Platform.OS` to ask for permissions — that branch
192
+ * lives here, once, so the two platforms cannot drift apart in host code.
193
+ *
194
+ * **Resolves only AFTER the user has answered the dialog**, with the resulting
195
+ * state — a status captured while the prompt is still up would be stale, and
196
+ * reporting it as the outcome would be a lie. A second call made while one is
197
+ * still in flight REJECTS rather than interleaving two prompt sequences.
198
+ * If the user never answers, the wait gives up after 120 s and resolves with the
199
+ * state as it is at that moment (still `'prompt'` for anything unanswered).
200
+ *
201
+ * **`options.permissions` can only narrow Bluetooth.** Neither native offers
202
+ * per-permission selection: each requests its whole required set behind one
203
+ * `includeBluetooth` / `requestBluetooth` flag. So the array is read as
204
+ * `includeBluetooth = permissions.includes('bluetooth')` (Bluetooth is included
205
+ * when `permissions` is omitted), and `location` and `motion` always ride the
206
+ * base set — **passing `['bluetooth']` alone still requests the base set.**
207
+ *
208
+ * `'activity'` is accepted in the array as a deprecated alias for `'motion'`.
209
+ *
210
+ * Native guidance on iOS is to call this once from a user-initiated flow rather
211
+ * than from app launch; native's `onlyIfNotDetermined` default (`true`) is what
212
+ * makes a launch-time call safe — it is left at the native default here.
213
+ *
214
+ * Android's `ACCESS_BACKGROUND_LOCATION` is deliberately NOT part of this call:
215
+ * Android 11+ requires it as a second prompt issued after the foreground grant,
216
+ * so it keeps its own entry point (`requestBackgroundLocationPermission`). The
217
+ * iOS expression of the same intent is native's `requestAlwaysLocation`, left at
218
+ * its default (`true`) here.
219
+ */
220
+ static requestPermissions(options?: PermissionRequestOptions): Promise<PermissionStatus>;
221
+ /**
222
+ * Requests `ACCESS_BACKGROUND_LOCATION` (Android 10+), required to keep
223
+ * collecting once the host app is backgrounded or the screen is off — without it
224
+ * the SDK refuses to start a session from the background and route geofences
225
+ * only fire in the foreground. **Android only.**
226
+ *
227
+ * This is a separate entry point because Android makes it one: from Android 11+
228
+ * the OS refuses to bundle background location into the foreground request, so it
229
+ * has to be a SECOND prompt issued after foreground location is granted, and
230
+ * asking earlier burns it on an automatic denial. The wrapper does not sequence
231
+ * the two calls for you — deciding when the user has been told why the app wants
232
+ * "Allow all the time" is the host's, not the wrapper's.
233
+ *
234
+ * On iOS the same intent is already inside `requestPermissions`, via native's
235
+ * `requestAlwaysLocation` (left at its default, `true`); there is no iOS
236
+ * counterpart to this method, so it rejects there rather than resolving a
237
+ * made-up answer.
238
+ *
239
+ * Resolves `true` when a request was actually issued (false below API 29 or when
240
+ * already granted).
97
241
  */
98
- static requestAllPermissions(requestAlwaysLocation?: boolean, requestBluetooth?: boolean): void;
242
+ static requestBackgroundLocationPermission(): Promise<boolean>;
99
243
  /**
100
244
  * Configures the iOS SDK's remote logging pipeline. No-op on Android (the
101
245
  * Android SDK currently configures remote logging via remote config / dev
@@ -158,5 +302,5 @@ declare class DoorstepAIModule {
158
302
  static disableDevMode(): Promise<boolean>;
159
303
  }
160
304
  export { DoorstepAIModule as DoorstepAI };
161
- export type { AddressType, LatLngObject, StartDeliveryOptions, SDKLogLevel, DeliveryStop, RouteGeofenceOptions, GeofenceSessionEvent, GeofenceSessionEventType, };
305
+ export type { AddressType, LatLngObject, StartDeliveryOptions, PermissionState, DoorstepPermissionType, PermissionStatus, PermissionRequestOptions, SDKLogLevel, DeliveryStop, RouteGeofenceOptions, GeofenceSessionEvent, GeofenceSessionEventType, };
162
306
  //# sourceMappingURL=DoorstepAI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DoorstepAI.d.ts","sourceRoot":"","sources":["../../../src/DoorstepAI.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAUxD,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB,EAAE,MAAM,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;GAKG;AACH,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qDAAqD;AACrD,KAAK,oBAAoB,GAAG;IAC1B,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,wBAAwB,GAAG,SAAS,GAAG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,2DAA2D;WAC9C,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IASjD;;;OAGG;WACU,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3D,2EAA2E;WAC9D,iBAAiB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAUzD;;;;OAIG;IACH,MAAM,CAAC,0BAA0B,CAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAC9C,mBAAmB,GAAG,SAAS;WAMrB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5D,0CAA0C;WAC7B,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAKtD,kCAAkC;WACrB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAIhD;AAED,OAAO,EAAE,gBAAgB,IAAI,UAAU,EAAE,CAAC;AAC1C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,CAAC"}
@@ -2,8 +2,19 @@ export declare function RootDoorstepAI(props: {
2
2
  apiKey: string;
3
3
  notificationTitle?: string;
4
4
  notificationText?: string;
5
- /** Opt-in: also request Bluetooth (BLE) permission. Off by default — only
6
- * needed if the `ble` config section is enabled for your fleet. */
5
+ /**
6
+ * Whether to include Bluetooth in the permission request: Android's "Nearby
7
+ * devices" grant, iOS's Bluetooth prompt. Defaults to ON, as both natives do.
8
+ * Set `false` to narrow the request to the base set (location + motion) — the
9
+ * only narrowing `requestPermissions` can honour.
10
+ */
7
11
  requestBluetooth?: boolean;
12
+ /**
13
+ * Run the second-phase `ACCESS_BACKGROUND_LOCATION` request on Android
14
+ * (default: on). Turn it off only if your app asks for background location from
15
+ * its own onboarding UI — without the grant the SDK cannot start a session while
16
+ * backgrounded and route geofences fire foreground-only.
17
+ */
18
+ requestBackgroundLocation?: boolean;
8
19
  }): import("react").JSX.Element;
9
20
  //# sourceMappingURL=RootDoorstepAI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RootDoorstepAI.d.ts","sourceRoot":"","sources":["../../../src/RootDoorstepAI.tsx"],"names":[],"mappings":"AAcA,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;wEACoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,+BAkEA"}
1
+ {"version":3,"file":"RootDoorstepAI.d.ts","sourceRoot":"","sources":["../../../src/RootDoorstepAI.tsx"],"names":[],"mappings":"AAcA,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,+BA4GA"}
@@ -1,5 +1,5 @@
1
1
  import { RootDoorstepAI } from './RootDoorstepAI';
2
2
  import { DoorstepAI } from './DoorstepAI';
3
- export type { AddressType, LatLngObject, StartDeliveryOptions, SDKLogLevel, DeliveryStop, RouteGeofenceOptions, GeofenceSessionEvent, GeofenceSessionEventType, } from './DoorstepAI';
3
+ export type { AddressType, LatLngObject, StartDeliveryOptions, PermissionState, DoorstepPermissionType, PermissionStatus, PermissionRequestOptions, SDKLogLevel, DeliveryStop, RouteGeofenceOptions, GeofenceSessionEvent, GeofenceSessionEventType, } from './DoorstepAI';
4
4
  export { DoorstepAI, RootDoorstepAI };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doorstepai/dropoff-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "doorstep.ai dropoff sdk for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -12,6 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "files": [
15
+ "CHANGELOG.md",
15
16
  "src",
16
17
  "lib",
17
18
  "android",
@@ -69,8 +69,12 @@ type GeofenceSessionEvent = {
69
69
  type StartDeliveryOptions = {
70
70
  /**
71
71
  * Hard upper bound on the delivery's tracking session in seconds. When the
72
- * timer fires the SDK calls `stopDelivery` automatically. Defaults to 7200
73
- * (2 hours) when not provided.
72
+ * timer fires the SDK calls `stopDelivery` automatically.
73
+ *
74
+ * Omit it for NO backstop — that is the native behaviour on both platforms.
75
+ * This wrapper used to substitute 3600 s here, which silently force-stopped
76
+ * every delivery at one hour and re-created a bug the native SDK had already
77
+ * removed. It now passes your value through untouched.
74
78
  */
75
79
  timeoutSeconds?: number;
76
80
  /**
@@ -98,12 +102,87 @@ type StartDeliveryOptions = {
98
102
  driverId?: string;
99
103
  };
100
104
 
105
+ /**
106
+ * The grant state of one permission, as the published wrapper API has always
107
+ * spelled it. `'prompt'` means "not determined yet — asking will show a dialog".
108
+ */
109
+ type PermissionState = 'granted' | 'denied' | 'prompt';
110
+
111
+ /**
112
+ * The permission domains the SDK uses, on BOTH platforms.
113
+ *
114
+ * - `location` — CoreLocation (iOS) / `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION` (Android).
115
+ * - `motion` — Motion & Fitness (iOS) / activity recognition (Android).
116
+ * - `bluetooth`— Bluetooth (iOS) / the "Nearby devices" group (Android 12+).
117
+ *
118
+ * The string `'activity'` is still ACCEPTED wherever a `DoorstepPermissionType`
119
+ * is passed, as a **deprecated alias for `'motion'`** — it was the published name
120
+ * in `@doorstepai/dropoff-sdk-capacitor` 1.0.4 and dropping it would break hosts.
121
+ * It is normalised to `'motion'` before it reaches native, and it is never a key
122
+ * of {@link PermissionStatus}.
123
+ */
124
+ type DoorstepPermissionType = 'location' | 'motion' | 'bluetooth';
125
+
126
+ /** The state of every permission domain the SDK uses. */
127
+ interface PermissionStatus {
128
+ permissions: Record<DoorstepPermissionType, PermissionState>;
129
+ }
130
+
131
+ /** Options for {@link DoorstepAIModule.requestPermissions}. */
132
+ interface PermissionRequestOptions {
133
+ /**
134
+ * If omitted, requests everything the native SDK asks for.
135
+ *
136
+ * **This array can only narrow Bluetooth.** Both natives request their whole
137
+ * required set behind a single `includeBluetooth` / `requestBluetooth` flag —
138
+ * neither exposes per-permission selection — so the array is read as
139
+ * `includeBluetooth = permissions.includes('bluetooth')` and `location` and
140
+ * `motion` always ride the base set. Passing `['bluetooth']` alone therefore
141
+ * still requests the base set as well. Documented rather than silently
142
+ * swallowed: an array the wrapper cannot honour would be a lie.
143
+ *
144
+ * `'activity'` is accepted as a deprecated alias for `'motion'`.
145
+ */
146
+ permissions?: Array<DoorstepPermissionType | 'activity'>;
147
+ }
148
+
149
+ /**
150
+ * `'activity'` → `'motion'`, applied once here so both bridges only ever see the
151
+ * canonical names. This is the ONE alias the public surface owes its published
152
+ * history; it is not a wrapper-owned permission list, and it never decides WHICH
153
+ * OS permissions get requested — native still owns that.
154
+ */
155
+ function normalizePermissionTypes(
156
+ permissions: Array<DoorstepPermissionType | 'activity'> | undefined
157
+ ): DoorstepPermissionType[] | undefined {
158
+ if (permissions == null) return undefined;
159
+ return permissions.map((p) =>
160
+ p === 'activity' ? 'motion' : p
161
+ ) as DoorstepPermissionType[];
162
+ }
163
+
101
164
  /**
102
165
  * Mirrors the iOS SDK's `SDKLogLevel` enum. Only used by
103
166
  * `configureRemoteLogging` (iOS only).
104
167
  */
105
168
  type SDKLogLevel = 'debug' | 'info' | 'warning' | 'error' | 'critical';
106
169
 
170
+ /**
171
+ * Rejects instead of resolving a fabricated value: the Android runtime-permission
172
+ * query helpers have no counterpart on iOS, and a helper that silently resolved
173
+ * `true`/`[]` would read as "granted" / "nothing needed" to a cross-platform host.
174
+ */
175
+ function unsupportedOnThisPlatform(
176
+ method: string,
177
+ supportedOn: 'iOS' | 'Android'
178
+ ): Promise<never> {
179
+ return Promise.reject(
180
+ new Error(
181
+ `DoorstepAI.${method} is ${supportedOn}-only; there is no native counterpart on ${Platform.OS}.`
182
+ )
183
+ );
184
+ }
185
+
107
186
  const SDK_LOG_LEVEL_RAW: Record<SDKLogLevel, number> = {
108
187
  debug: 0,
109
188
  info: 1,
@@ -112,8 +191,6 @@ const SDK_LOG_LEVEL_RAW: Record<SDKLogLevel, number> = {
112
191
  critical: 4,
113
192
  };
114
193
 
115
- const DEFAULT_TIMEOUT_SECONDS = 3600;
116
-
117
194
  class DoorstepAIModule {
118
195
  static isInitialized = false;
119
196
 
@@ -140,18 +217,160 @@ class DoorstepAIModule {
140
217
  DoorstepAI.setApiKey(apiKey);
141
218
  }
142
219
 
220
+ // ---- Runtime permissions -------------------------------------------------
221
+ // Every method below is a pass-through to the native SDK's own permission API.
222
+ // The SDK owns the permission list and the prompt ordering; this wrapper used to
223
+ // keep a second implementation beside it and drifted — it requested
224
+ // ACCESS_FINE_LOCATION with no ACCESS_COARSE_LOCATION (Android 12+ ignores that
225
+ // request outright), never requested ACCESS_BACKGROUND_LOCATION or
226
+ // POST_NOTIFICATIONS at all, and requested ACTIVITY_RECOGNITION, which native
227
+ // deliberately does not require (`internal/SensorCollectionManager.kt:139`).
228
+
143
229
  /**
144
- * Triggers iOS Motion/Fitness + Location permission prompts up-front so the
145
- * host app does not need to manage them itself. No-op on Android — use
146
- * `PermissionsAndroid` (already wired into `RootDoorstepAI`).
230
+ * The dangerous runtime permissions the native SDK needs on THIS device,
231
+ * version-gated. **Android only.**
232
+ *
233
+ * Foreground set only — it deliberately excludes `ACCESS_BACKGROUND_LOCATION`,
234
+ * which Android 11+ requires be requested separately and only after foreground
235
+ * location is granted (see `requestBackgroundLocationPermission`).
236
+ *
237
+ * Feed it to your own permission UI (e.g. `PermissionsAndroid.requestMultiple`)
238
+ * when you want the grant results in JS — it is the same list `requestPermissions`
239
+ * asks for, so the two cannot diverge.
240
+ *
241
+ * @param includeBluetooth include `BLUETOOTH_SCAN` (Android 12+) and
242
+ * `NEARBY_WIFI_DEVICES` (Android 13+). Native default: `true`.
147
243
  */
148
- static requestAllPermissions(
149
- requestAlwaysLocation: boolean = true,
150
- requestBluetooth: boolean = false
151
- ) {
152
- if (Platform.OS === 'ios') {
153
- DoorstepAI.requestAllPermissions(requestAlwaysLocation, requestBluetooth);
244
+ static getRequiredPermissions(includeBluetooth?: boolean): Promise<string[]> {
245
+ if (Platform.OS !== 'android') {
246
+ return unsupportedOnThisPlatform('getRequiredPermissions', 'Android');
247
+ }
248
+ return DoorstepAI.getRequiredPermissions(includeBluetooth ?? null);
249
+ }
250
+
251
+ /**
252
+ * True when every foreground permission the SDK needs is currently granted.
253
+ * **Android only.**
254
+ *
255
+ * @param includeBluetooth native default here is `false`, unlike the request
256
+ * methods — Bluetooth is optional, so a denied "Nearby devices" grant must not
257
+ * make the SDK look unusable.
258
+ */
259
+ static hasRequiredPermissions(includeBluetooth?: boolean): Promise<boolean> {
260
+ if (Platform.OS !== 'android') {
261
+ return unsupportedOnThisPlatform('hasRequiredPermissions', 'Android');
262
+ }
263
+ return DoorstepAI.hasRequiredPermissions(includeBluetooth ?? null);
264
+ }
265
+
266
+ /**
267
+ * True when `ACCESS_BACKGROUND_LOCATION` is granted (always true below API 29,
268
+ * where it is not a separate grant). **Android only.**
269
+ */
270
+ static hasBackgroundLocationPermission(): Promise<boolean> {
271
+ if (Platform.OS !== 'android') {
272
+ return unsupportedOnThisPlatform(
273
+ 'hasBackgroundLocationPermission',
274
+ 'Android'
275
+ );
276
+ }
277
+ return DoorstepAI.hasBackgroundLocationPermission();
278
+ }
279
+
280
+ /**
281
+ * The current grant state of every permission domain the SDK uses, on both
282
+ * platforms. Pure observation — it reads the platform's own status APIs
283
+ * (`CLLocationManager.authorizationStatus` / `CMMotionActivityManager.
284
+ * authorizationStatus()` / `CBManager.authorization` on iOS,
285
+ * `ContextCompat.checkSelfPermission` on Android) and shows no dialog.
286
+ *
287
+ * The set of permissions read comes from the native SDK
288
+ * (`DoorstepAI.getRequiredPermissions()` on Android); the wrapper keeps no
289
+ * permission list of its own, it only reports the state of what native names.
290
+ *
291
+ * A domain the native SDK requires no runtime grant for on this OS version
292
+ * reports `'granted'` — e.g. `motion` on Android, where sensor collection needs
293
+ * no runtime permission, and `bluetooth` below Android 12.
294
+ */
295
+ static checkPermissions(): Promise<PermissionStatus> {
296
+ return DoorstepAI.checkPermissions();
297
+ }
298
+
299
+ /**
300
+ * The one permission requester. Asks for every runtime permission the SDK needs
301
+ * on whichever platform the app is running: Android's foreground runtime
302
+ * permissions (`DoorstepAI.requestPermissions(activity, requestCode,
303
+ * includeBluetooth)`, only the not-yet-granted ones) and iOS's Location +
304
+ * Motion/Fitness + Bluetooth prompts
305
+ * (`DoorstepAI.requestAllPermissions(requestAlwaysLocation:requestBluetooth:onlyIfNotDetermined:)`).
306
+ *
307
+ * Hosts must not branch on `Platform.OS` to ask for permissions — that branch
308
+ * lives here, once, so the two platforms cannot drift apart in host code.
309
+ *
310
+ * **Resolves only AFTER the user has answered the dialog**, with the resulting
311
+ * state — a status captured while the prompt is still up would be stale, and
312
+ * reporting it as the outcome would be a lie. A second call made while one is
313
+ * still in flight REJECTS rather than interleaving two prompt sequences.
314
+ * If the user never answers, the wait gives up after 120 s and resolves with the
315
+ * state as it is at that moment (still `'prompt'` for anything unanswered).
316
+ *
317
+ * **`options.permissions` can only narrow Bluetooth.** Neither native offers
318
+ * per-permission selection: each requests its whole required set behind one
319
+ * `includeBluetooth` / `requestBluetooth` flag. So the array is read as
320
+ * `includeBluetooth = permissions.includes('bluetooth')` (Bluetooth is included
321
+ * when `permissions` is omitted), and `location` and `motion` always ride the
322
+ * base set — **passing `['bluetooth']` alone still requests the base set.**
323
+ *
324
+ * `'activity'` is accepted in the array as a deprecated alias for `'motion'`.
325
+ *
326
+ * Native guidance on iOS is to call this once from a user-initiated flow rather
327
+ * than from app launch; native's `onlyIfNotDetermined` default (`true`) is what
328
+ * makes a launch-time call safe — it is left at the native default here.
329
+ *
330
+ * Android's `ACCESS_BACKGROUND_LOCATION` is deliberately NOT part of this call:
331
+ * Android 11+ requires it as a second prompt issued after the foreground grant,
332
+ * so it keeps its own entry point (`requestBackgroundLocationPermission`). The
333
+ * iOS expression of the same intent is native's `requestAlwaysLocation`, left at
334
+ * its default (`true`) here.
335
+ */
336
+ static requestPermissions(
337
+ options?: PermissionRequestOptions
338
+ ): Promise<PermissionStatus> {
339
+ const permissions = normalizePermissionTypes(options?.permissions);
340
+ return DoorstepAI.requestPermissions(
341
+ permissions == null ? null : { permissions }
342
+ );
343
+ }
344
+
345
+ /**
346
+ * Requests `ACCESS_BACKGROUND_LOCATION` (Android 10+), required to keep
347
+ * collecting once the host app is backgrounded or the screen is off — without it
348
+ * the SDK refuses to start a session from the background and route geofences
349
+ * only fire in the foreground. **Android only.**
350
+ *
351
+ * This is a separate entry point because Android makes it one: from Android 11+
352
+ * the OS refuses to bundle background location into the foreground request, so it
353
+ * has to be a SECOND prompt issued after foreground location is granted, and
354
+ * asking earlier burns it on an automatic denial. The wrapper does not sequence
355
+ * the two calls for you — deciding when the user has been told why the app wants
356
+ * "Allow all the time" is the host's, not the wrapper's.
357
+ *
358
+ * On iOS the same intent is already inside `requestPermissions`, via native's
359
+ * `requestAlwaysLocation` (left at its default, `true`); there is no iOS
360
+ * counterpart to this method, so it rejects there rather than resolving a
361
+ * made-up answer.
362
+ *
363
+ * Resolves `true` when a request was actually issued (false below API 29 or when
364
+ * already granted).
365
+ */
366
+ static requestBackgroundLocationPermission(): Promise<boolean> {
367
+ if (Platform.OS !== 'android') {
368
+ return unsupportedOnThisPlatform(
369
+ 'requestBackgroundLocationPermission',
370
+ 'Android'
371
+ );
154
372
  }
373
+ return DoorstepAI.requestBackgroundLocationPermission();
155
374
  }
156
375
 
157
376
  /**
@@ -185,8 +404,7 @@ class DoorstepAIModule {
185
404
  options?: StartDeliveryOptions
186
405
  ) {
187
406
  try {
188
- const timeout =
189
- timeoutSeconds ?? options?.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
407
+ const timeout = timeoutSeconds ?? options?.timeoutSeconds;
190
408
  const autoStop = options?.autoStopAfterDropoffSeconds ?? null;
191
409
  const customerId = options?.customerId ?? null;
192
410
  const driverId = options?.driverId ?? null;
@@ -232,8 +450,7 @@ class DoorstepAIModule {
232
450
  options?: StartDeliveryOptions
233
451
  ) {
234
452
  try {
235
- const timeout =
236
- timeoutSeconds ?? options?.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
453
+ const timeout = timeoutSeconds ?? options?.timeoutSeconds;
237
454
  const customerId = options?.customerId ?? null;
238
455
  const driverId = options?.driverId ?? null;
239
456
  // Android's deprecated startDeliveryByPlusCode does not accept
@@ -279,8 +496,7 @@ class DoorstepAIModule {
279
496
  options?: StartDeliveryOptions
280
497
  ) {
281
498
  try {
282
- const timeout =
283
- timeoutSeconds ?? options?.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
499
+ const timeout = timeoutSeconds ?? options?.timeoutSeconds;
284
500
  const autoStop = options?.autoStopAfterDropoffSeconds ?? null;
285
501
  const customerId = options?.customerId ?? null;
286
502
  const driverId = options?.driverId ?? null;
@@ -325,8 +541,7 @@ class DoorstepAIModule {
325
541
  options?: StartDeliveryOptions
326
542
  ) {
327
543
  try {
328
- const timeout =
329
- timeoutSeconds ?? options?.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
544
+ const timeout = timeoutSeconds ?? options?.timeoutSeconds;
330
545
  const autoStop = options?.autoStopAfterDropoffSeconds ?? null;
331
546
  const customerId = options?.customerId ?? null;
332
547
  const driverId = options?.driverId ?? null;
@@ -376,8 +591,7 @@ class DoorstepAIModule {
376
591
  options?: StartDeliveryOptions
377
592
  ) {
378
593
  try {
379
- const timeout =
380
- timeoutSeconds ?? options?.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS;
594
+ const timeout = timeoutSeconds ?? options?.timeoutSeconds;
381
595
  const customerId = options?.customerId ?? null;
382
596
  const driverId = options?.driverId ?? null;
383
597
  // Android's deprecated startDeliveryByLatLng does not accept
@@ -588,6 +802,10 @@ export type {
588
802
  AddressType,
589
803
  LatLngObject,
590
804
  StartDeliveryOptions,
805
+ PermissionState,
806
+ DoorstepPermissionType,
807
+ PermissionStatus,
808
+ PermissionRequestOptions,
591
809
  SDKLogLevel,
592
810
  DeliveryStop,
593
811
  RouteGeofenceOptions,