@wayq/beekon-rn 0.0.5 → 0.0.7

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 (64) hide show
  1. package/BeekonRn.podspec +4 -2
  2. package/CHANGELOG.md +127 -0
  3. package/README.md +303 -81
  4. package/android/build.gradle +3 -2
  5. package/android/src/main/java/in/wayq/beekonrn/BeekonRnModule.kt +164 -7
  6. package/ios/BeekonRn.mm +23 -0
  7. package/ios/BeekonRn.swift +199 -10
  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 +7784 -2697
  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 +111 -3
  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 +7784 -2697
  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 +111 -3
  19. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/Modules/BeekonKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +7784 -2697
  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 +111 -3
  22. package/ios/Frameworks/BeekonKit.xcframework/ios-arm64_x86_64-simulator/BeekonKit.framework/_CodeSignature/CodeResources +1 -1
  23. package/lib/module/NativeBeekonRn.js +20 -0
  24. package/lib/module/NativeBeekonRn.js.map +1 -1
  25. package/lib/module/beekon.js +90 -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 +98 -4
  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/module/types/license.js +2 -0
  35. package/lib/module/types/license.js.map +1 -0
  36. package/lib/typescript/src/NativeBeekonRn.d.ts +84 -0
  37. package/lib/typescript/src/NativeBeekonRn.d.ts.map +1 -1
  38. package/lib/typescript/src/beekon.d.ts +45 -1
  39. package/lib/typescript/src/beekon.d.ts.map +1 -1
  40. package/lib/typescript/src/index.d.ts +3 -1
  41. package/lib/typescript/src/index.d.ts.map +1 -1
  42. package/lib/typescript/src/internal/mappers.d.ts +12 -1
  43. package/lib/typescript/src/internal/mappers.d.ts.map +1 -1
  44. package/lib/typescript/src/types/auth.d.ts +99 -0
  45. package/lib/typescript/src/types/auth.d.ts.map +1 -0
  46. package/lib/typescript/src/types/config.d.ts +29 -0
  47. package/lib/typescript/src/types/config.d.ts.map +1 -1
  48. package/lib/typescript/src/types/enums.d.ts +14 -0
  49. package/lib/typescript/src/types/enums.d.ts.map +1 -1
  50. package/lib/typescript/src/types/error.d.ts +14 -4
  51. package/lib/typescript/src/types/error.d.ts.map +1 -1
  52. package/lib/typescript/src/types/license.d.ts +50 -0
  53. package/lib/typescript/src/types/license.d.ts.map +1 -0
  54. package/package.json +10 -2
  55. package/scripts/fetch-beekonkit.sh +4 -4
  56. package/src/NativeBeekonRn.ts +93 -0
  57. package/src/beekon.ts +104 -6
  58. package/src/index.tsx +4 -0
  59. package/src/internal/mappers.ts +109 -1
  60. package/src/types/auth.ts +101 -0
  61. package/src/types/config.ts +29 -0
  62. package/src/types/enums.ts +16 -0
  63. package/src/types/error.ts +19 -4
  64. package/src/types/license.ts +47 -0
@@ -1,3 +1,4 @@
1
+ import type { AuthConfig } from './auth';
1
2
  import type { AccuracyMode, StationaryMode } from './enums';
2
3
 
3
4
  /**
@@ -11,6 +12,14 @@ export type NotificationConfig = {
11
12
  title?: string;
12
13
  /** Notification body text. Defaults to no body. */
13
14
  text?: string;
15
+ /**
16
+ * Status-bar icon, given as an Android drawable or mipmap resource **name**
17
+ * — `"ic_notification"`, `"drawable/ic_x"`, or `"mipmap/ic_x"`. Android
18
+ * renders the small icon from its alpha channel only, so supply a monochrome
19
+ * silhouette on a transparent background. Falls back to the host app's
20
+ * launcher icon when omitted or unresolvable.
21
+ */
22
+ smallIcon?: string;
14
23
  };
15
24
 
16
25
  /**
@@ -30,6 +39,13 @@ export type SyncConfig = {
30
39
  intervalSeconds?: number;
31
40
  /** Maximum locations per upload. Clamped to `[1, 1000]`. Default: `100`. */
32
41
  batchSize?: number;
42
+ /**
43
+ * Declarative token-refresh recipe. When set, the SDK attaches and natively
44
+ * refreshes the access token (proactively before expiry, reactively on
45
+ * `401`/`403`). Omit to keep the legacy static-{@link SyncConfig.headers}
46
+ * behaviour. Requires the native SDK ≥ 0.0.6. See {@link AuthConfig}.
47
+ */
48
+ auth?: AuthConfig;
33
49
  };
34
50
 
35
51
  /**
@@ -62,4 +78,17 @@ export type BeekonConfig = {
62
78
  sync?: SyncConfig;
63
79
  /** Android-only notification overrides. Ignored on iOS. */
64
80
  notification?: NotificationConfig;
81
+ /**
82
+ * Beekon license token (a `license-format-v1` JWS). The **highest-priority**
83
+ * supply channel (spec §9): it overrides the platform manifest value
84
+ * (`in.wayq.beekon.license` meta-data on Android, `BeekonLicenseKey` in
85
+ * `Info.plist` on iOS). `undefined`, blank, or whitespace-only means unset —
86
+ * the SDK falls through to the manifest, then to evaluation mode.
87
+ *
88
+ * The license **never blocks** the SDK; observe the outcome via
89
+ * {@link Beekon.licenseStatus} / {@link Beekon.onLicenseStatus}. Safe to commit
90
+ * to source control: a token is app-id-bound and product-bound, so it is
91
+ * useless to anyone else. Default: unset.
92
+ */
93
+ licenseKey?: string;
65
94
  };
@@ -62,3 +62,19 @@ export type ActivityType =
62
62
  | 'cycling'
63
63
  | 'automotive'
64
64
  | 'unknown';
65
+
66
+ /**
67
+ * How the access token is attached to upload requests (token refresh).
68
+ *
69
+ * - `'bearer'` — `Authorization: Bearer <accessToken>` (JWT / OAuth2 style, default).
70
+ * - `'raw'` — `Authorization: <accessToken>` (the raw token, no scheme).
71
+ */
72
+ export type AuthStrategy = 'bearer' | 'raw';
73
+
74
+ /**
75
+ * Encoding of the token-refresh request body.
76
+ *
77
+ * - `'form'` — `application/x-www-form-urlencoded` (default; most OAuth2 endpoints).
78
+ * - `'json'` — `application/json`.
79
+ */
80
+ export type AuthBodyFormat = 'form' | 'json';
@@ -1,14 +1,29 @@
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 =
22
+ | 'storage'
23
+ | 'invalidGeofence'
24
+ | 'permissionDenied'
25
+ | 'locationServicesDisabled'
26
+ | 'locationUnavailable';
12
27
 
13
28
  /**
14
29
  * Typed error surfaced from the bridge. The native module rejects promises with
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Why an invalid license token failed verification (license-format-v1 §8.1).
3
+ * These are the exact wire-stable identifiers — the string names *are* the
4
+ * contract, shared verbatim with both native SDKs.
5
+ *
6
+ * - `'malformed'` — unparseable: bad encoding, structure, header, or claim types.
7
+ * - `'unknownKey'` — signed with a key this SDK build does not embed (update the SDK).
8
+ * - `'badSignature'` — the ES256 signature does not verify.
9
+ * - `'appIdMismatch'` — the license does not cover this application id.
10
+ * - `'productMismatch'` — the license does not cover this framework (here, `rn`).
11
+ * - `'unsupportedVersion'` — the token's claim schema is newer than this SDK understands.
12
+ */
13
+ export type LicenseInvalidReason =
14
+ | 'malformed'
15
+ | 'unknownKey'
16
+ | 'badSignature'
17
+ | 'appIdMismatch'
18
+ | 'productMismatch'
19
+ | 'unsupportedVersion';
20
+
21
+ /**
22
+ * License verification status for the **current platform** (license-format-v1
23
+ * §8). Purely observational — no status ever blocks, degrades, or delays the
24
+ * SDK. Use the `status` field as a discriminator.
25
+ *
26
+ * - `'notDetermined'` — before the first (lazy) validation completes.
27
+ * - `'evaluation'` — no license key supplied through any channel; running free.
28
+ * - `'expired'` — the license's expiry has passed.
29
+ * - `'updateEntitlementLapsed'` — this SDK build is newer than the license's
30
+ * covered update window. Still fully functional; renew to cover newer releases.
31
+ * - `'licensed'` — a valid license covering this app, framework, and SDK release;
32
+ * carries the opaque `tier` and `entitlements` (empty when the token carried none).
33
+ * - `'invalid'` — verification failed; see {@link LicenseInvalidReason}.
34
+ *
35
+ * **Platform divergence is legal** (spec §8.2): Android and iOS validate
36
+ * independently, so for one app the two platforms may report different statuses
37
+ * (e.g. a license scoped to `["android"]` reads `licensed` on Android and
38
+ * `invalid` / `productMismatch` on iOS). This value reflects only the platform
39
+ * you are running on; the wrapper never merges across platforms.
40
+ */
41
+ export type LicenseStatus =
42
+ | { status: 'notDetermined' }
43
+ | { status: 'evaluation' }
44
+ | { status: 'expired' }
45
+ | { status: 'updateEntitlementLapsed' }
46
+ | { status: 'licensed'; tier: string; entitlements: string[] }
47
+ | { status: 'invalid'; reason: LicenseInvalidReason };