@mentra/bluetooth-sdk 3.1.0-dev.8 → 3.1.0-dev.9

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.
@@ -0,0 +1,104 @@
1
+ import Foundation
2
+ @testable import MentraBluetoothSDK
3
+ import XCTest
4
+
5
+ final class MentraLivePairingAdvertisementTests: XCTestCase {
6
+ func testConnectionCallbackPolicyRejectsPairingYieldAndStaleAttempts() {
7
+ XCTAssertFalse(
8
+ MentraLiveConnectionAttemptPolicy.shouldAcceptDidConnect(
9
+ pairingYieldActive: true,
10
+ matchesActiveAttempt: true
11
+ )
12
+ )
13
+ XCTAssertFalse(
14
+ MentraLiveConnectionAttemptPolicy.shouldAcceptDidConnect(
15
+ pairingYieldActive: false,
16
+ matchesActiveAttempt: false
17
+ )
18
+ )
19
+ XCTAssertTrue(
20
+ MentraLiveConnectionAttemptPolicy.shouldAcceptDidConnect(
21
+ pairingYieldActive: false,
22
+ matchesActiveAttempt: true
23
+ )
24
+ )
25
+ }
26
+
27
+ func testParsesMarkedSecurePairingAdvertisement() {
28
+ let result = MentraLivePairingAdvertisement.parse(
29
+ coreBluetoothManufacturerData: securePayload(pairingFlag: 1)
30
+ )
31
+
32
+ XCTAssertEqual(result?.pairingCode, "1234")
33
+ XCTAssertEqual(result?.pairingMode, true)
34
+ }
35
+
36
+ func testParsesMarkedOwnedAdvertisement() {
37
+ let result = MentraLivePairingAdvertisement.parse(
38
+ coreBluetoothManufacturerData: securePayload(pairingFlag: 0)
39
+ )
40
+
41
+ XCTAssertEqual(result?.pairingCode, "1234")
42
+ XCTAssertEqual(result?.pairingMode, false)
43
+ }
44
+
45
+ func testRejectsLegacyPayloadThatMatchesOldVersionCapabilityHeuristic() {
46
+ var payload = legacyPayload()
47
+ payload[2 + 5] = 0
48
+ payload[2 + 6] = 1
49
+ payload[2 + 7] = 1
50
+ payload[2 + 8] = 0x34
51
+ payload[2 + 9] = 0x12
52
+
53
+ XCTAssertNil(
54
+ MentraLivePairingAdvertisement.parse(coreBluetoothManufacturerData: payload)
55
+ )
56
+ }
57
+
58
+ func testRejectsUnmarkedFirstGenerationSecureTrailer() {
59
+ var payload = securePayload(pairingFlag: 1)
60
+ payload[2 + 10] = 0x11
61
+ payload[2 + 11] = 0x22
62
+
63
+ XCTAssertNil(
64
+ MentraLivePairingAdvertisement.parse(coreBluetoothManufacturerData: payload)
65
+ )
66
+ }
67
+
68
+ func testRejectsEveryLegacyVersionAndCapabilityCombination() {
69
+ for version in UInt8.min ... UInt8.max {
70
+ for capability in UInt8.min ... UInt8.max {
71
+ var payload = legacyPayload()
72
+ payload[2 + 5] = 1
73
+ payload[2 + 6] = version
74
+ payload[2 + 7] = capability
75
+ payload[2 + 10] = 0x4D
76
+ // Offset 11 is padding in the legacy format, so it cannot contain the second
77
+ // non-zero marker byte.
78
+ payload[2 + 11] = 0
79
+ XCTAssertNil(
80
+ MentraLivePairingAdvertisement.parse(coreBluetoothManufacturerData: payload)
81
+ )
82
+ }
83
+ }
84
+ }
85
+
86
+ private func legacyPayload() -> Data {
87
+ var data = Data(repeating: 0, count: 29)
88
+ data[0] = 0x22
89
+ data[1] = 0xB8
90
+ return data
91
+ }
92
+
93
+ private func securePayload(pairingFlag: UInt8) -> Data {
94
+ var data = legacyPayload()
95
+ data[2 + 5] = pairingFlag
96
+ data[2 + 6] = 2
97
+ data[2 + 7] = 1
98
+ data[2 + 8] = 0x34
99
+ data[2 + 9] = 0x12
100
+ data[2 + 10] = 0x4D
101
+ data[2 + 11] = 0x50
102
+ return data
103
+ }
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.1.0-dev.8",
3
+ "version": "3.1.0-dev.9",
4
4
  "description": "SDK for communicating with smart glasses",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -652,20 +652,15 @@ export type PairFailureEvent = {
652
652
 
653
653
  export type PairingInfoEvent = {
654
654
  had_previous_bond: boolean
655
- /** 16-char uppercase hex transfer id when secure pairing is active. */
656
- transfer_id?: string
657
655
  pairing_code?: string
658
656
  classic_bond_ready?: boolean
659
657
  secure_pairing_capable?: boolean
660
658
  protocol_version?: number
661
- /** Credential binding mode negotiated for this transfer, when reported by the glasses. */
662
- binding?: "ctkd" | "temporal" | "none" | string
663
659
  }
664
660
 
665
661
  export type EnteringPairingModeEvent = {
666
662
  window_ms: number
667
663
  reason?: string
668
- txn?: number
669
664
  }
670
665
 
671
666
  export type OwnerReplacedEvent = {
@@ -12,9 +12,9 @@ export interface BluetoothSdkReleaseMetadata {
12
12
  export const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "3.1.0",
15
- "releaseIdentity": "3.1.0-dev.8",
16
- "releaseSetId": "mentra-3.1.0-dev.8",
17
- "sourceCommit": "09289ddd1a233812de92935b2127b401d2603ce5",
18
- "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.8/mentra-live-ota-3.1.0-dev.8.json",
19
- "otaManifestSha256": "8fbea7589345658dc5dffcb394229ffc5c52fbe75352acb8f6827d83290ce750"
15
+ "releaseIdentity": "3.1.0-dev.9",
16
+ "releaseSetId": "mentra-3.1.0-dev.9",
17
+ "sourceCommit": "24201a3bb26253c4ce435d1fc125b0164774ebec",
18
+ "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-v3.1.0-dev.9/mentra-live-ota-3.1.0-dev.9.json",
19
+ "otaManifestSha256": "214d92c8894033eaab276e668cb553c79990005d3330d23aaf499a514dc08cff"
20
20
  })