@wayq/beekon-rn 0.0.5 → 0.0.6

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 (59) hide show
  1. package/BeekonRn.podspec +4 -2
  2. package/CHANGELOG.md +103 -0
  3. package/README.md +303 -81
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +113 -7
  6. package/ios/BeekonRn.mm +13 -0
  7. package/ios/BeekonRn.swift +113 -9
  8. package/ios/Frameworks/BeekonKit.xcframework/Info.plist +5 -5
  9. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/BeekonKit +0 -0
  10. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Info.plist +0 -0
  11. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.abi.json +5399 -1463
  12. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  13. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios.swiftinterface +77 -2
  14. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/BeekonKit +0 -0
  15. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Info.plist +0 -0
  16. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.abi.json +5399 -1463
  17. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  18. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +77 -2
  19. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +5399 -1463
  20. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  21. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +77 -2
  22. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +1 -1
  23. package/lib/module/NativeBeekonRn.js +13 -0
  24. package/lib/module/NativeBeekonRn.js.map +1 -1
  25. package/lib/module/beekon.js +56 -7
  26. package/lib/module/beekon.js.map +1 -1
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/internal/mappers.js +50 -3
  29. package/lib/module/internal/mappers.js.map +1 -1
  30. package/lib/module/types/auth.js +4 -0
  31. package/lib/module/types/auth.js.map +1 -0
  32. package/lib/module/types/error.js +13 -3
  33. package/lib/module/types/error.js.map +1 -1
  34. package/lib/typescript/src/NativeBeekonRn.d.ts +48 -0
  35. package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
  36. package/lib/typescript/src/beekon.d.ts +30 -1
  37. package/lib/typescript/src/beekon.d.ts.map +1 -1
  38. package/lib/typescript/src/index.d.ts +2 -1
  39. package/lib/typescript/src/index.d.ts.map +1 -1
  40. package/lib/typescript/src/internal/mappers.d.ts +5 -1
  41. package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
  42. package/lib/typescript/src/types/auth.d.ts +99 -0
  43. package/lib/typescript/src/types/auth.d.ts.map +1 -0
  44. package/lib/typescript/src/types/config.d.ts +16 -0
  45. package/lib/typescript/src/types/config.d.ts.map +1 -1
  46. package/lib/typescript/src/types/enums.d.ts +14 -0
  47. package/lib/typescript/src/types/enums.d.ts.map +1 -1
  48. package/lib/typescript/src/types/error.d.ts +14 -4
  49. package/lib/typescript/src/types/error.d.ts.map +1 -1
  50. package/package.json +5 -1
  51. package/scripts/fetch-beekonkit.sh +4 -4
  52. package/src/NativeBeekonRn.ts +55 -0
  53. package/src/beekon.ts +66 -6
  54. package/src/index.tsx +3 -0
  55. package/src/internal/mappers.ts +59 -1
  56. package/src/types/auth.ts +101 -0
  57. package/src/types/config.ts +16 -0
  58. package/src/types/enums.ts +16 -0
  59. package/src/types/error.ts +19 -4
@@ -1,4 +1,6 @@
1
+ import type { AuthTokens } from './types/auth';
1
2
  import type { BeekonConfig } from './types/config';
3
+ import type { AccuracyMode } from './types/enums';
2
4
  import type { BeekonGeofence, GeofenceEvent } from './types/geofence';
3
5
  import type { Location } from './types/location';
4
6
  import type { BeekonState } from './types/state';
@@ -49,6 +51,26 @@ declare class BeekonImpl {
49
51
  * in the AppDelegate). See the README.
50
52
  */
51
53
  resumeIfNeeded(): Promise<void>;
54
+ /**
55
+ * Return a single fresh fix on demand — for the moment a host needs an
56
+ * immediate position (e.g. the instant a trip starts).
57
+ *
58
+ * Independent of tracking: works whether or not a session is running and never
59
+ * starts, stops, or disturbs one. The fix is not persisted and does not appear
60
+ * on `onLocation` — it is returned here only, tagged `'manual'`.
61
+ *
62
+ * Resolves `null` if no usable fix arrives within `timeoutMs` (default
63
+ * 15000). `accuracy` overrides the configured mode for this call only;
64
+ * omitted uses the configured mode.
65
+ *
66
+ * Throws `BeekonError` with kind `'permissionDenied'`,
67
+ * `'locationServicesDisabled'`, or `'locationUnavailable'` on a precondition
68
+ * failure.
69
+ */
70
+ getCurrentLocation(options?: {
71
+ timeoutMs?: number;
72
+ accuracy?: AccuracyMode;
73
+ }): Promise<Location | null>;
52
74
  /**
53
75
  * Read persisted fixes in the inclusive range `[from, to]`, oldest first.
54
76
  * Reads come from the SDK's local storage (Room on Android, GRDB on iOS) — the
@@ -59,7 +81,7 @@ declare class BeekonImpl {
59
81
  */
60
82
  getLocations(from: Date, to: Date): Promise<Location[]>;
61
83
  /**
62
- * Delete stored locations captured at or before `before` (all of them when
84
+ * Delete stored locations captured before `before` (all of them when
63
85
  * `before` is omitted). Returns the number of rows removed. Throws
64
86
  * `BeekonError` with kind `'storage'` on a failure.
65
87
  */
@@ -109,6 +131,13 @@ declare class BeekonImpl {
109
131
  * Returns an unsubscribe function.
110
132
  */
111
133
  onSyncStatus(cb: (s: SyncStatus) => void): () => void;
134
+ /**
135
+ * Subscribe to token rotations the SDK performed during a native refresh (see
136
+ * `SyncConfig.auth`). Mirror them into your own session store. The latest
137
+ * rotation is delivered to new subscribers immediately (replay-1). Sensitive —
138
+ * delivered in-process only, never logged. Returns an unsubscribe function.
139
+ */
140
+ onAuthTokens(cb: (t: AuthTokens) => void): () => void;
112
141
  }
113
142
  export declare const Beekon: BeekonImpl;
114
143
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"beekon.d.ts","sourceRoot":"","sources":["../../../src/beekon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8F/C;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,UAAU;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IAEtC;;;;;OAKG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK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;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ3C;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,+EAA+E;IACzE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;;;OAIG;IACG,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D,2DAA2D;IACrD,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,0CAA0C;IACpC,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAKhD;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI;IAIjD;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;IAIjD;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI;IAI3D;;;;OAIG;IACH,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;IAIrD;;;;;OAKG;IACH,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;CAGtD;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export { Beekon } from './beekon';
2
2
  export type { BeekonConfig, SyncConfig, NotificationConfig, } from './types/config';
3
- export type { AccuracyMode, StationaryMode, LocationTrigger, LocationQuality, MotionState, ActivityType, } from './types/enums';
3
+ export type { AccuracyMode, StationaryMode, LocationTrigger, LocationQuality, MotionState, ActivityType, AuthStrategy, AuthBodyFormat, } from './types/enums';
4
+ export type { AuthConfig, AuthResponseMapping, AuthTokens } from './types/auth';
4
5
  export type { Location } from './types/location';
5
6
  export type { BeekonGeofence, GeofenceEvent, Transition, } from './types/geofence';
6
7
  export type { BeekonState, StopReason } from './types/state';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EACV,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EACV,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -1,17 +1,21 @@
1
+ import type { AuthConfig, AuthTokens } from '../types/auth';
1
2
  import type { BeekonConfig } from '../types/config';
2
3
  import type { BeekonGeofence, GeofenceEvent } from '../types/geofence';
3
4
  import type { Location } from '../types/location';
4
5
  import type { BeekonState } from '../types/state';
5
6
  import type { SyncStatus } from '../types/sync';
6
- import type { WireConfig, WireGeofence, WireGeofenceEvent, WireKeyValue, WireLocation, WireState, WireSyncStatus } from '../NativeBeekonRn';
7
+ import type { WireAuthConfig, WireAuthTokens, WireConfig, WireGeofence, WireGeofenceEvent, WireKeyValue, WireLocation, WireState, WireSyncStatus } from '../NativeBeekonRn';
7
8
  export declare function recordToEntries(record: Record<string, string> | undefined): WireKeyValue[];
8
9
  export declare function configToWire(config: BeekonConfig): WireConfig;
9
10
  export declare function geofenceToWire(g: BeekonGeofence): WireGeofence;
11
+ export declare function authToWire(a: AuthConfig): WireAuthConfig;
10
12
  export declare function wireToLocation(w: WireLocation): Location;
11
13
  export declare function wireToGeofence(w: WireGeofence): BeekonGeofence;
12
14
  export declare function wireToGeofenceEvent(w: WireGeofenceEvent): GeofenceEvent;
13
15
  export declare function wireToState(w: WireState): BeekonState;
14
16
  export declare function wireToSyncStatus(w: WireSyncStatus): SyncStatus;
17
+ /** `expiresAtMs` (epoch millis) becomes a `Date`; `null` propagates faithfully. */
18
+ export declare function wireToAuthTokens(w: WireAuthTokens): AuthTokens;
15
19
  /**
16
20
  * Re-throw a native promise rejection as a typed {@link BeekonError}. The native
17
21
  * modules encode the kind in the error-code string (`STORAGE_FAILURE`,
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AASpD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACf,MAAM,mBAAmB,CAAC;AAiB3B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACzC,YAAY,EAAE,CAGhB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CA0B7D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,cAAc,GAAG,YAAY,CAS9D;AAID,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,QAAQ,CA0CxD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,cAAc,CAS9D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAOvE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,WAAW,CAYrD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,cAAc,GAAG,UAAU,CAW9D;AAoCD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAQtD"}
1
+ {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../../../src/internal/mappers.ts"],"names":[],"mappings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GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAQtD"}
@@ -0,0 +1,99 @@
1
+ import type { AuthBodyFormat, AuthStrategy } from './enums';
2
+ /**
3
+ * Where the SDK reads rotated tokens from the JSON response to a refresh
4
+ * request. Mirrors the native `AuthResponseMapping` (iOS) / `ResponseMapping`
5
+ * (Android).
6
+ *
7
+ * Each value is a response key. An omitted field falls back to common-name
8
+ * detection: `access_token`/`accessToken`/`token` for the access token,
9
+ * `refresh_token`/`refreshToken` for a rotated refresh token, and `expires_in`
10
+ * (relative seconds) or `expires_at`/`expires` (absolute epoch seconds) for the
11
+ * expiry. The default (all-omitted) is pure common-name detection.
12
+ */
13
+ export type AuthResponseMapping = {
14
+ /** Response key holding the new access token. Omitted uses common-name detection. */
15
+ accessToken?: string;
16
+ /** Response key holding a rotated refresh token. Omitted uses common-name detection. */
17
+ refreshToken?: string;
18
+ /** Response key holding a relative lifetime in seconds. Omitted uses detection. */
19
+ expiresIn?: string;
20
+ /** Response key holding an absolute expiry in epoch seconds. Omitted uses detection. */
21
+ expiresAt?: string;
22
+ };
23
+ /**
24
+ * Declarative recipe for native token refresh, set on `SyncConfig.auth`.
25
+ * Mirrors the native `AuthConfig`.
26
+ *
27
+ * When present, the SDK attaches the access token to every upload (per
28
+ * {@link AuthConfig.strategy}), refreshes it **proactively** before
29
+ * {@link AuthConfig.expiresAt} and **reactively** on a `401`/`403`, then retries
30
+ * the upload — all natively, so it works in the background and on a cold launch
31
+ * with no host involvement. Omit {@link AuthConfig.refreshUrl} to disable
32
+ * refresh and keep the legacy behaviour (a `401`/`403` pauses sync and surfaces
33
+ * `SyncFailure 'auth'`).
34
+ *
35
+ * **Tokens are a seed, not config.** {@link AuthConfig.accessToken},
36
+ * {@link AuthConfig.refreshToken} and {@link AuthConfig.expiresAt} are supplied
37
+ * once; the SDK then owns and rotates the live token set in secure storage
38
+ * (Keychain / encrypted prefs). Observe rotations via `Beekon.onAuthTokens()` to
39
+ * mirror the tokens into your own session store.
40
+ *
41
+ * Requires the native SDK ≥ 0.0.6; with an older native binary the recipe is
42
+ * ignored and only static `SyncConfig.headers` apply.
43
+ */
44
+ export type AuthConfig = {
45
+ /** Initial access token. A seed: the SDK owns and rotates it after first persist. */
46
+ accessToken?: string;
47
+ /** Initial refresh token POSTed to {@link AuthConfig.refreshUrl}. A seed. */
48
+ refreshToken?: string;
49
+ /** Absolute expiry of {@link AuthConfig.accessToken}. Omitted disables proactive refresh. */
50
+ expiresAt?: Date;
51
+ /** How the access token is attached. Default: `'bearer'`. */
52
+ strategy?: AuthStrategy;
53
+ /** Authorization server's refresh endpoint. Omitted disables refresh. */
54
+ refreshUrl?: string;
55
+ /**
56
+ * Form fields POSTed to {@link AuthConfig.refreshUrl}. A value containing
57
+ * `{refreshToken}` is substituted with the current refresh token. Default: empty.
58
+ */
59
+ refreshPayload?: Record<string, string>;
60
+ /**
61
+ * Headers sent on the refresh request. A value containing `{accessToken}` is
62
+ * substituted with the current access token. Default:
63
+ * `{ Authorization: 'Bearer {accessToken}' }`.
64
+ */
65
+ refreshHeaders?: Record<string, string>;
66
+ /** Encoding of the refresh request body. Default: `'form'`. */
67
+ refreshBodyFormat?: AuthBodyFormat;
68
+ /** Where to read rotated tokens from the refresh response. Default: detection. */
69
+ responseMapping?: AuthResponseMapping;
70
+ /** Seconds before {@link AuthConfig.expiresAt} at which a proactive refresh fires. Default: `60`. */
71
+ skewMarginSeconds?: number;
72
+ /**
73
+ * Optional monotonic re-seed signal. When greater than the SDK's stored epoch,
74
+ * a re-supplied seed replaces the rotated token set (e.g. after the user
75
+ * re-authenticates). Omitted adopts a re-supplied seed only when no token has
76
+ * been stored yet.
77
+ */
78
+ seedEpoch?: number;
79
+ };
80
+ /**
81
+ * A token set the SDK rotated, delivered via `Beekon.onAuthTokens()`. Mirrors
82
+ * the native `AuthTokens` (iOS) / `TokenRefresh` (Android).
83
+ *
84
+ * Treat these as sensitive: they are delivered in-process only and are never
85
+ * logged or persisted to plaintext. Use them to mirror the SDK's current
86
+ * credentials into your own session store. The latest rotation is replayed to
87
+ * new subscribers (replay-1).
88
+ */
89
+ export type AuthTokens = {
90
+ /** The rotated access token now in use. */
91
+ accessToken: string;
92
+ /** The current refresh token (rotated if the server returned a new one), or `null`. */
93
+ refreshToken: string | null;
94
+ /** Absolute expiry of {@link AuthTokens.accessToken}, or `null` if the response carried none. */
95
+ expiresAt: Date | null;
96
+ /** The SDK's monotonic token generation, incremented on each successful refresh. */
97
+ epoch: number;
98
+ };
99
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,kFAAkF;IAClF,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iGAAiG;IACjG,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { AuthConfig } from './auth';
1
2
  import type { AccuracyMode, StationaryMode } from './enums';
2
3
  /**
3
4
  * Foreground-service notification overrides. **Android-only** — the platform
@@ -10,6 +11,14 @@ export type NotificationConfig = {
10
11
  title?: string;
11
12
  /** Notification body text. Defaults to no body. */
12
13
  text?: string;
14
+ /**
15
+ * Status-bar icon, given as an Android drawable or mipmap resource **name**
16
+ * — `"ic_notification"`, `"drawable/ic_x"`, or `"mipmap/ic_x"`. Android
17
+ * renders the small icon from its alpha channel only, so supply a monochrome
18
+ * silhouette on a transparent background. Falls back to the host app's
19
+ * launcher icon when omitted or unresolvable.
20
+ */
21
+ smallIcon?: string;
13
22
  };
14
23
  /**
15
24
  * Server-upload configuration. Presence of {@link BeekonConfig.sync} turns on
@@ -28,6 +37,13 @@ export type SyncConfig = {
28
37
  intervalSeconds?: number;
29
38
  /** Maximum locations per upload. Clamped to `[1, 1000]`. Default: `100`. */
30
39
  batchSize?: number;
40
+ /**
41
+ * Declarative token-refresh recipe. When set, the SDK attaches and natively
42
+ * refreshes the access token (proactively before expiry, reactively on
43
+ * `401`/`403`). Omit to keep the legacy static-{@link SyncConfig.headers}
44
+ * behaviour. Requires the native SDK ≥ 0.0.6. See {@link AuthConfig}.
45
+ */
46
+ auth?: AuthConfig;
31
47
  };
32
48
  /**
33
49
  * Tracking configuration. Every field is optional — `Beekon.start()` falls back
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,yEAAyE;IACzE,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,8EAA8E;IAC9E,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,wDAAwD;IACxD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,sDAAsD;IACtD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,6EAA6E;IAC7E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,kBAAkB,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CACnC,CAAC"}
@@ -45,4 +45,18 @@ export type MotionState = 'moving' | 'stationary' | 'unknown';
45
45
  * {@link BeekonConfig.detectActivity} is enabled; otherwise `null`.
46
46
  */
47
47
  export type ActivityType = 'stationary' | 'walking' | 'running' | 'cycling' | 'automotive' | 'unknown';
48
+ /**
49
+ * How the access token is attached to upload requests (token refresh).
50
+ *
51
+ * - `'bearer'` — `Authorization: Bearer <accessToken>` (JWT / OAuth2 style, default).
52
+ * - `'raw'` — `Authorization: <accessToken>` (the raw token, no scheme).
53
+ */
54
+ export type AuthStrategy = 'bearer' | 'raw';
55
+ /**
56
+ * Encoding of the token-refresh request body.
57
+ *
58
+ * - `'form'` — `application/x-www-form-urlencoded` (default; most OAuth2 endpoints).
59
+ * - `'json'` — `application/json`.
60
+ */
61
+ export type AuthBodyFormat = 'form' | 'json';
48
62
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/types/enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAExE,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,SAAS,GACT,SAAS,GACT,SAAS,GACT,YAAY,GACZ,SAAS,CAAC"}
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/types/enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAExE,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,SAAS,GACT,SAAS,GACT,SAAS,GACT,YAAY,GACZ,SAAS,CAAC;AAEd;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC"}
@@ -1,14 +1,24 @@
1
1
  /**
2
- * Error kinds thrown across the bridge. These are the **only** errors Beekon
3
- * throws — permission / location-services / lifecycle problems never throw; they
4
- * surface on the `onState` stream as `stopped(reason)` instead.
2
+ * Error kinds thrown across the bridge.
3
+ *
4
+ * Lifecycle problems on the tracking path never throw — they surface on the
5
+ * `onState` stream as `stopped(reason)`. The exceptions are the storage/geofence
6
+ * kinds below and the precondition kinds thrown by the explicit one-shot
7
+ * `getCurrentLocation()` (which has no `onState` arc of its own to report on; a
8
+ * plain timeout returns `null` instead of throwing).
5
9
  *
6
10
  * - `'storage'` — a local-store (SQLite) read/write failed. Thrown by
7
11
  * `getLocations()`, `deleteLocations()`, and `pendingUploadCount()`.
8
12
  * - `'invalidGeofence'` — a geofence passed to `addGeofences()` failed
9
13
  * validation (empty/oversized id, or non-positive radius).
14
+ * - `'permissionDenied'` — location permission is missing. Thrown by
15
+ * `getCurrentLocation()`.
16
+ * - `'locationServicesDisabled'` — system location services are off. Thrown by
17
+ * `getCurrentLocation()`.
18
+ * - `'locationUnavailable'` — location is otherwise unavailable (e.g. Play
19
+ * Services absent/old). Thrown by `getCurrentLocation()`.
10
20
  */
11
- export type BeekonErrorKind = 'storage' | 'invalidGeofence';
21
+ export type BeekonErrorKind = 'storage' | 'invalidGeofence' | 'permissionDenied' | 'locationServicesDisabled' | 'locationUnavailable';
12
22
  /**
13
23
  * Typed error surfaced from the bridge. The native module rejects promises with
14
24
  * the kind encoded as the error code; the facade re-wraps into this.
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/types/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAE5D;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,eAAe,CAAC;gBAE1B,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/types/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,iBAAiB,GACjB,kBAAkB,GAClB,0BAA0B,GAC1B,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,eAAe,CAAC;gBAE1B,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wayq/beekon-rn",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "React Native binding for the Beekon location SDK (Android + iOS).",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -20,6 +20,7 @@
20
20
  "scripts/fetch-beekonkit.sh",
21
21
  "*.podspec",
22
22
  "LICENSE.txt",
23
+ "CHANGELOG.md",
23
24
  "!ios/build",
24
25
  "!android/build",
25
26
  "!android/gradle",
@@ -45,9 +46,12 @@
45
46
  "android",
46
47
  "location",
47
48
  "tracking",
49
+ "location-tracking",
48
50
  "gps",
51
+ "gps-tracking",
49
52
  "background-location",
50
53
  "geolocation",
54
+ "geofencing",
51
55
  "beekon",
52
56
  "turbo-module"
53
57
  ],
@@ -13,12 +13,12 @@
13
13
 
14
14
  set -euo pipefail
15
15
 
16
- VERSION="0.0.5"
16
+ VERSION="0.0.6"
17
17
  URL="https://github.com/wayqteam/beekon-ios-binary/releases/download/v${VERSION}/BeekonKit.xcframework.zip"
18
- # SHA256 of the v0.0.5 BeekonKit.xcframework.zip. Matches the SwiftPM
19
- # `binaryTarget` checksum in beekon-ios-binary's Package.swift at tag v0.0.5
18
+ # SHA256 of the v0.0.6 BeekonKit.xcframework.zip. Matches the SwiftPM
19
+ # `binaryTarget` checksum in beekon-ios-binary's Package.swift at tag v0.0.6
20
20
  # (SwiftPM's compute-checksum is the SHA256 of the zip).
21
- EXPECTED_SHA="437bf493d7de19d8df9599da097be162796a8304eb2d7826cf2505c33d4603f7"
21
+ EXPECTED_SHA="eb0cd87c869cdbce5374569efa2d47f0f7e6c01ce18461c0653ef701163cf343"
22
22
 
23
23
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
24
24
  DEST_DIR="${ROOT}/ios/Frameworks"
@@ -27,17 +27,47 @@ export type WireKeyValue = {
27
27
  value: string;
28
28
  };
29
29
 
30
+ /** Flat wire form of `AuthResponseMapping`. Omitted keys use common-name detection. */
31
+ export type WireAuthResponseMapping = {
32
+ accessToken?: string;
33
+ refreshToken?: string;
34
+ expiresIn?: string;
35
+ expiresAt?: string;
36
+ };
37
+
38
+ /**
39
+ * Flat wire form of `AuthConfig` on {@link WireSyncConfig.auth}. Enums travel as
40
+ * strings (`strategy`: 'bearer'|'raw'; `refreshBodyFormat`: 'form'|'json'),
41
+ * string maps as `WireKeyValue[]`, and `expiresAtMs` is epoch milliseconds.
42
+ */
43
+ export type WireAuthConfig = {
44
+ accessToken?: string;
45
+ refreshToken?: string;
46
+ expiresAtMs?: number;
47
+ strategy: string;
48
+ refreshUrl?: string;
49
+ refreshPayload: WireKeyValue[];
50
+ refreshHeaders: WireKeyValue[];
51
+ refreshBodyFormat: string;
52
+ responseMapping: WireAuthResponseMapping;
53
+ skewMarginSeconds: number;
54
+ seedEpoch?: number;
55
+ };
56
+
30
57
  export type WireSyncConfig = {
31
58
  url: string;
32
59
  headers: WireKeyValue[];
33
60
  intervalSeconds: number;
34
61
  batchSize: number;
62
+ /** Token-refresh recipe; omitted keeps static-header auth. */
63
+ auth?: WireAuthConfig;
35
64
  };
36
65
 
37
66
  /** Android-only foreground-service notification overrides. iOS ignores it. */
38
67
  export type WireNotificationConfig = {
39
68
  title?: string;
40
69
  text?: string;
70
+ smallIcon?: string;
41
71
  };
42
72
 
43
73
  export type WireConfig = {
@@ -112,6 +142,17 @@ export type WireSyncStatus = {
112
142
  failure?: string;
113
143
  };
114
144
 
145
+ /**
146
+ * A token set the SDK rotated, delivered on `onAuthTokens`. `expiresAtMs` is
147
+ * epoch milliseconds; both it and `refreshToken` are `null` when absent.
148
+ */
149
+ export type WireAuthTokens = {
150
+ accessToken: string;
151
+ refreshToken: string | null;
152
+ expiresAtMs: number | null;
153
+ epoch: number;
154
+ };
155
+
115
156
  export interface Spec extends TurboModule {
116
157
  /**
117
158
  * The config crosses as an untyped object (`ReadableMap` on Android,
@@ -125,6 +166,19 @@ export interface Spec extends TurboModule {
125
166
  stop(): Promise<void>;
126
167
  resumeIfNeeded(): Promise<void>;
127
168
 
169
+ /**
170
+ * One immediate fix. `accuracy` `''` uses the configured mode (a plain
171
+ * `string` rather than `string | null` for portable Codegen, matching
172
+ * `deleteLocations`). Resolves a 0- or 1-element array — empty means timeout /
173
+ * no fix — rather than a nullable struct, which Codegen does not portably
174
+ * support. Rejects with `PERMISSION_DENIED` / `LOCATION_SERVICES_DISABLED` /
175
+ * `LOCATION_UNAVAILABLE` on a precondition failure.
176
+ */
177
+ getCurrentLocation(
178
+ timeoutMs: number,
179
+ accuracy: string
180
+ ): Promise<WireLocation[]>;
181
+
128
182
  getLocations(fromMs: number, toMs: number): Promise<WireLocation[]>;
129
183
  /**
130
184
  * A negative `beforeMs` deletes all stored locations (the wire encoding of
@@ -145,6 +199,7 @@ export interface Spec extends TurboModule {
145
199
  readonly onLocation: CodegenTypes.EventEmitter<WireLocation>;
146
200
  readonly onGeofenceEvent: CodegenTypes.EventEmitter<WireGeofenceEvent>;
147
201
  readonly onSyncStatus: CodegenTypes.EventEmitter<WireSyncStatus>;
202
+ readonly onAuthTokens: CodegenTypes.EventEmitter<WireAuthTokens>;
148
203
  }
149
204
 
150
205
  export default TurboModuleRegistry.getEnforcing<Spec>('BeekonRn');
package/src/beekon.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import NativeBeekon from './NativeBeekonRn';
2
+ import type { AuthTokens } from './types/auth';
2
3
  import type { BeekonConfig } from './types/config';
4
+ import type { AccuracyMode } from './types/enums';
3
5
  import type { BeekonGeofence, GeofenceEvent } from './types/geofence';
4
6
  import type { Location } from './types/location';
5
7
  import type { BeekonState } from './types/state';
@@ -9,6 +11,7 @@ import {
9
11
  geofenceToWire,
10
12
  recordToEntries,
11
13
  rethrowAsBeekonError,
14
+ wireToAuthTokens,
12
15
  wireToGeofence,
13
16
  wireToGeofenceEvent,
14
17
  wireToLocation,
@@ -19,11 +22,11 @@ import {
19
22
  type Listener<T> = (value: T) => void;
20
23
 
21
24
  /**
22
- * Fans the four native EventEmitters out to multiple JS subscribers and adds
23
- * replay-1 semantics for `state` / `syncStatus` (RN EventEmitters don't replay,
24
- * so we cache the latest value and hand it to new subscribers immediately —
25
- * matching the native StateFlow / AsyncStream contract). `location` /
26
- * `geofenceEvent` are plain fan-out with no replay.
25
+ * Fans the five native EventEmitters out to multiple JS subscribers and adds
26
+ * replay-1 semantics for `state` / `syncStatus` / `authTokens` (RN EventEmitters
27
+ * don't replay, so we cache the latest value and hand it to new subscribers
28
+ * immediately — matching the native StateFlow / AsyncStream contract).
29
+ * `location` / `geofenceEvent` are plain fan-out with no replay.
27
30
  *
28
31
  * Native subscriptions are opened once, on first use, and kept for the app
29
32
  * lifetime — the native module collects its flows continuously regardless, so
@@ -35,8 +38,10 @@ class EventHub {
35
38
  private readonly locationListeners = new Set<Listener<Location>>();
36
39
  private readonly geofenceListeners = new Set<Listener<GeofenceEvent>>();
37
40
  private readonly syncListeners = new Set<Listener<SyncStatus>>();
41
+ private readonly authTokenListeners = new Set<Listener<AuthTokens>>();
38
42
  private lastState: BeekonState | undefined;
39
43
  private lastSyncStatus: SyncStatus | undefined;
44
+ private lastAuthTokens: AuthTokens | undefined;
40
45
 
41
46
  /** Idempotent: opens the native subscriptions the first time it is called. */
42
47
  ensureSubscribed(): void {
@@ -60,6 +65,11 @@ class EventHub {
60
65
  this.lastSyncStatus = s;
61
66
  this.syncListeners.forEach((cb) => cb(s));
62
67
  });
68
+ NativeBeekon.onAuthTokens((w) => {
69
+ const t = wireToAuthTokens(w);
70
+ this.lastAuthTokens = t;
71
+ this.authTokenListeners.forEach((cb) => cb(t));
72
+ });
63
73
  }
64
74
 
65
75
  onState(cb: Listener<BeekonState>): () => void {
@@ -95,6 +105,15 @@ class EventHub {
95
105
  this.syncListeners.delete(cb);
96
106
  };
97
107
  }
108
+
109
+ onAuthTokens(cb: Listener<AuthTokens>): () => void {
110
+ this.ensureSubscribed();
111
+ this.authTokenListeners.add(cb);
112
+ if (this.lastAuthTokens !== undefined) cb(this.lastAuthTokens);
113
+ return () => {
114
+ this.authTokenListeners.delete(cb);
115
+ };
116
+ }
98
117
  }
99
118
 
100
119
  /**
@@ -160,6 +179,37 @@ class BeekonImpl {
160
179
  await NativeBeekon.resumeIfNeeded();
161
180
  }
162
181
 
182
+ /**
183
+ * Return a single fresh fix on demand — for the moment a host needs an
184
+ * immediate position (e.g. the instant a trip starts).
185
+ *
186
+ * Independent of tracking: works whether or not a session is running and never
187
+ * starts, stops, or disturbs one. The fix is not persisted and does not appear
188
+ * on `onLocation` — it is returned here only, tagged `'manual'`.
189
+ *
190
+ * Resolves `null` if no usable fix arrives within `timeoutMs` (default
191
+ * 15000). `accuracy` overrides the configured mode for this call only;
192
+ * omitted uses the configured mode.
193
+ *
194
+ * Throws `BeekonError` with kind `'permissionDenied'`,
195
+ * `'locationServicesDisabled'`, or `'locationUnavailable'` on a precondition
196
+ * failure.
197
+ */
198
+ async getCurrentLocation(options?: {
199
+ timeoutMs?: number;
200
+ accuracy?: AccuracyMode;
201
+ }): Promise<Location | null> {
202
+ try {
203
+ const wires = await NativeBeekon.getCurrentLocation(
204
+ options?.timeoutMs ?? 15000,
205
+ options?.accuracy ?? ''
206
+ );
207
+ return wires.length === 0 ? null : wireToLocation(wires[0]!);
208
+ } catch (e) {
209
+ rethrowAsBeekonError(e);
210
+ }
211
+ }
212
+
163
213
  /**
164
214
  * Read persisted fixes in the inclusive range `[from, to]`, oldest first.
165
215
  * Reads come from the SDK's local storage (Room on Android, GRDB on iOS) — the
@@ -181,7 +231,7 @@ class BeekonImpl {
181
231
  }
182
232
 
183
233
  /**
184
- * Delete stored locations captured at or before `before` (all of them when
234
+ * Delete stored locations captured before `before` (all of them when
185
235
  * `before` is omitted). Returns the number of rows removed. Throws
186
236
  * `BeekonError` with kind `'storage'` on a failure.
187
237
  */
@@ -277,6 +327,16 @@ class BeekonImpl {
277
327
  onSyncStatus(cb: (s: SyncStatus) => void): () => void {
278
328
  return this.hub.onSyncStatus(cb);
279
329
  }
330
+
331
+ /**
332
+ * Subscribe to token rotations the SDK performed during a native refresh (see
333
+ * `SyncConfig.auth`). Mirror them into your own session store. The latest
334
+ * rotation is delivered to new subscribers immediately (replay-1). Sensitive —
335
+ * delivered in-process only, never logged. Returns an unsubscribe function.
336
+ */
337
+ onAuthTokens(cb: (t: AuthTokens) => void): () => void {
338
+ return this.hub.onAuthTokens(cb);
339
+ }
280
340
  }
281
341
 
282
342
  export const Beekon = new BeekonImpl();
package/src/index.tsx CHANGED
@@ -12,7 +12,10 @@ export type {
12
12
  LocationQuality,
13
13
  MotionState,
14
14
  ActivityType,
15
+ AuthStrategy,
16
+ AuthBodyFormat,
15
17
  } from './types/enums';
18
+ export type { AuthConfig, AuthResponseMapping, AuthTokens } from './types/auth';
16
19
  export type { Location } from './types/location';
17
20
  export type {
18
21
  BeekonGeofence,