@blueid/access-capacitor 0.93.0 → 0.95.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 (28) hide show
  1. package/dist/esm/BlueCore_pb.d.ts +20 -0
  2. package/dist/esm/BlueCore_pb.js +25 -0
  3. package/dist/esm/BlueCore_pb.js.map +1 -1
  4. package/dist/esm/BlueSDK_pb.d.ts +72 -12
  5. package/dist/esm/BlueSDK_pb.js +24 -9
  6. package/dist/esm/BlueSDK_pb.js.map +1 -1
  7. package/dist/plugin.cjs.js +49 -9
  8. package/dist/plugin.cjs.js.map +1 -1
  9. package/dist/plugin.js +49 -9
  10. package/dist/plugin.js.map +1 -1
  11. package/ios/CBlueIDAccess.xcframework/Info.plist +8 -8
  12. package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +5 -0
  13. package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
  14. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +5 -0
  15. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
  16. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +5 -0
  17. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
  18. package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +209 -58
  19. package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +20 -0
  20. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalSession.swift → BlueAccessDeviceModalSession.swift} +5 -5
  21. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalView.swift → BlueAccessDeviceModalView.swift} +11 -22
  22. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal+Extensions.swift +14 -0
  23. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal.swift +50 -2
  24. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalSession.swift +56 -0
  25. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalView.swift +237 -0
  26. package/ios/Plugin/BlueIDAccessSDK/BlueSDK.pb.swift +310 -40
  27. package/ios/Plugin/BlueIDAccessSDK/BlueTaskRunner.swift +155 -0
  28. package/package.json +1 -1
@@ -10,7 +10,7 @@
10
10
  <key>HeadersPath</key>
11
11
  <string>Headers</string>
12
12
  <key>LibraryIdentifier</key>
13
- <string>ios-arm64_x86_64-simulator</string>
13
+ <string>macos-arm64_x86_64</string>
14
14
  <key>LibraryPath</key>
15
15
  <string>libCBlueIDAccess.a</string>
16
16
  <key>SupportedArchitectures</key>
@@ -19,9 +19,7 @@
19
19
  <string>x86_64</string>
20
20
  </array>
21
21
  <key>SupportedPlatform</key>
22
- <string>ios</string>
23
- <key>SupportedPlatformVariant</key>
24
- <string>simulator</string>
22
+ <string>macos</string>
25
23
  </dict>
26
24
  <dict>
27
25
  <key>BinaryPath</key>
@@ -29,16 +27,15 @@
29
27
  <key>HeadersPath</key>
30
28
  <string>Headers</string>
31
29
  <key>LibraryIdentifier</key>
32
- <string>macos-arm64_x86_64</string>
30
+ <string>ios-arm64</string>
33
31
  <key>LibraryPath</key>
34
32
  <string>libCBlueIDAccess.a</string>
35
33
  <key>SupportedArchitectures</key>
36
34
  <array>
37
35
  <string>arm64</string>
38
- <string>x86_64</string>
39
36
  </array>
40
37
  <key>SupportedPlatform</key>
41
- <string>macos</string>
38
+ <string>ios</string>
42
39
  </dict>
43
40
  <dict>
44
41
  <key>BinaryPath</key>
@@ -46,15 +43,18 @@
46
43
  <key>HeadersPath</key>
47
44
  <string>Headers</string>
48
45
  <key>LibraryIdentifier</key>
49
- <string>ios-arm64</string>
46
+ <string>ios-arm64_x86_64-simulator</string>
50
47
  <key>LibraryPath</key>
51
48
  <string>libCBlueIDAccess.a</string>
52
49
  <key>SupportedArchitectures</key>
53
50
  <array>
54
51
  <string>arm64</string>
52
+ <string>x86_64</string>
55
53
  </array>
56
54
  <key>SupportedPlatform</key>
57
55
  <string>ios</string>
56
+ <key>SupportedPlatformVariant</key>
57
+ <string>simulator</string>
58
58
  </dict>
59
59
  </array>
60
60
  <key>CFBundlePackageType</key>
@@ -105,6 +105,11 @@ typedef enum BlueReturnCode {
105
105
  BlueReturnCode_SdkDecodeJsonFailed = -414,
106
106
  BlueReturnCode_SdkFetchDataFailed = -415,
107
107
  BlueReturnCode_SdkTimeout = -416,
108
+ BlueReturnCode_SdkGetAuthenticationTokenFailed = -417,
109
+ BlueReturnCode_SdkUpdateDeviceFailed = -418,
110
+ BlueReturnCode_SdkGetBlacklistEntriesFailed = -419,
111
+ BlueReturnCode_SdkGetSystemStatusFailed = -420,
112
+ BlueReturnCode_SdkWaitDeviceToRestartFailed = -421,
108
113
  BlueReturnCode_OssMAReturnCodeStart = -1000,
109
114
  BlueReturnCode_OssMAReturnCodeEnd = -1100
110
115
  } BlueReturnCode_t;
@@ -105,6 +105,11 @@ typedef enum BlueReturnCode {
105
105
  BlueReturnCode_SdkDecodeJsonFailed = -414,
106
106
  BlueReturnCode_SdkFetchDataFailed = -415,
107
107
  BlueReturnCode_SdkTimeout = -416,
108
+ BlueReturnCode_SdkGetAuthenticationTokenFailed = -417,
109
+ BlueReturnCode_SdkUpdateDeviceFailed = -418,
110
+ BlueReturnCode_SdkGetBlacklistEntriesFailed = -419,
111
+ BlueReturnCode_SdkGetSystemStatusFailed = -420,
112
+ BlueReturnCode_SdkWaitDeviceToRestartFailed = -421,
108
113
  BlueReturnCode_OssMAReturnCodeStart = -1000,
109
114
  BlueReturnCode_OssMAReturnCodeEnd = -1100
110
115
  } BlueReturnCode_t;
@@ -105,6 +105,11 @@ typedef enum BlueReturnCode {
105
105
  BlueReturnCode_SdkDecodeJsonFailed = -414,
106
106
  BlueReturnCode_SdkFetchDataFailed = -415,
107
107
  BlueReturnCode_SdkTimeout = -416,
108
+ BlueReturnCode_SdkGetAuthenticationTokenFailed = -417,
109
+ BlueReturnCode_SdkUpdateDeviceFailed = -418,
110
+ BlueReturnCode_SdkGetBlacklistEntriesFailed = -419,
111
+ BlueReturnCode_SdkGetSystemStatusFailed = -420,
112
+ BlueReturnCode_SdkWaitDeviceToRestartFailed = -421,
108
113
  BlueReturnCode_OssMAReturnCodeStart = -1000,
109
114
  BlueReturnCode_OssMAReturnCodeEnd = -1100
110
115
  } BlueReturnCode_t;
@@ -1,4 +1,5 @@
1
1
  import Foundation
2
+ import Combine
2
3
  import SwiftProtobuf
3
4
 
4
5
  internal let blueAccessCredentialsKeyChain = BlueKeychain(attrService: "blueid.accessCredentials")
@@ -6,6 +7,8 @@ internal let blueAccessAuthenticationTokensKeyChain = BlueKeychain(attrService:
6
7
  internal let blueAccessDevicesStorage = BlueStorage(collection: "blueid.accessDevices")
7
8
  internal let blueAccessOssSettingsKeyChain = BlueKeychain(attrService: "blueid.accessOssSettings")
8
9
 
10
+ // TODO: Split into separate files
11
+
9
12
  public class BlueAddAccessCredentialCommand: BlueSdkAsyncCommand {
10
13
  internal override func runAsync(arg0: Any?, arg1: Any?, arg2: Any?) async throws -> Any? {
11
14
  return try await runAsync(credential: try blueCastArg(BlueAccessCredential.self, arg0))
@@ -124,19 +127,29 @@ public struct BlueGetAccessDevicesCommand: BlueCommand {
124
127
  }
125
128
 
126
129
  public class BlueSynchronizeAccessDeviceCommand: BlueSdkAsyncCommand {
130
+ public enum BlueSynchronizeAccessTaskId {
131
+ case getAuthenticationToken
132
+ case getDeviceConfig
133
+ case updateDeviceConfig
134
+ case updateDeviceTime
135
+ case waitForRestart
136
+ case pushEventLogs
137
+ case pushSystemLogs
138
+ case getBlacklistEntries
139
+ case deployBlacklistEntries
140
+ case getSystemStatus
141
+ case pushSystemStatus
142
+ }
143
+
127
144
  internal override func runAsync(arg0: Any? = nil, arg1: Any? = nil, arg2: Any? = nil) async throws -> Any? {
128
- if #available(macOS 10.15, *) {
129
- return try await runAsync(
130
- credentialID: try blueCastArg(String.self, arg0),
131
- deviceID: try blueCastArg(String.self, arg1)
132
- )
133
- } else {
134
- throw BlueError(.sdkUnsupportedPlatform)
135
- }
145
+ return try await runAsync(
146
+ credentialID: try blueCastArg(String.self, arg0),
147
+ deviceID: try blueCastArg(String.self, arg1),
148
+ showModal: try blueCastArg(Bool.self, arg2)
149
+ )
136
150
  }
137
151
 
138
- @available(macOS 10.15, *)
139
- public func runAsync(credentialID: String, deviceID: String) async throws -> BlueSystemStatus? {
152
+ public func runAsync(credentialID: String, deviceID: String, showModal: Bool? = false) async throws -> BlueSystemStatus? {
140
153
  guard let device = blueGetDevice(deviceID) else {
141
154
  throw BlueError(.sdkDeviceNotFound)
142
155
  }
@@ -145,66 +158,207 @@ public class BlueSynchronizeAccessDeviceCommand: BlueSdkAsyncCommand {
145
158
  throw BlueError(.sdkCredentialNotFound)
146
159
  }
147
160
 
148
- let tokenAuthentication = try await sdkService.authenticationTokenService
149
- .getTokenAuthentication(credential: credential)
150
-
151
- let config = try await getBlueSystemConfig(deviceID: deviceID, with: tokenAuthentication)
161
+ let tasks = [
162
+ BlueTask(
163
+ id: BlueSynchronizeAccessTaskId.getAuthenticationToken,
164
+ label: blueI18n.syncDeviceGetAuthenticationTokenTaskLabel
165
+ ) { _ in
166
+ .result(try await self.getAuthenticationToken(credential))
167
+ },
168
+
169
+ BlueTask(
170
+ id: BlueSynchronizeAccessTaskId.getDeviceConfig,
171
+ label: blueI18n.syncDeviceRetrieveDeviceConfigurationTaskLabel
172
+ ) { runner in
173
+ let tokenAuthentication: BlueTokenAuthentication = try runner.getResult(BlueSynchronizeAccessTaskId.getAuthenticationToken)
174
+
175
+ return .result(try await self.getBlueSystemConfig(deviceID: deviceID, with: tokenAuthentication))
176
+ },
177
+
178
+ BlueTask(
179
+ id: BlueSynchronizeAccessTaskId.updateDeviceConfig,
180
+ label: blueI18n.syncDeviceUpdateDeviceConfigurationTaskLabel
181
+ ) { runner in
182
+ let config: BlueSystemConfig? = try runner.getResult(BlueSynchronizeAccessTaskId.getDeviceConfig)
183
+
184
+ let status: BlueSystemStatus = try await self.updateDevice(deviceID, config)
185
+
186
+ device.updateInfo(systemStatus: status)
187
+
188
+ return .resultWithStatus(status, config == nil ? .skipped: .succeeded)
189
+ },
190
+
191
+ BlueTask(
192
+ id: BlueSynchronizeAccessTaskId.updateDeviceTime,
193
+ label: blueI18n.syncDeviceUpdateDeviceTimeTaskLabel
194
+ ) { runner in
195
+ let status: BlueSystemStatus = try runner.getResult(BlueSynchronizeAccessTaskId.updateDeviceConfig)
196
+
197
+ return .resultWithStatus(nil, status.settings.timeWasSet == true ? .succeeded : .skipped)
198
+ },
199
+
200
+ BlueTask(
201
+ id: BlueSynchronizeAccessTaskId.waitForRestart,
202
+ label: blueI18n.syncDeviceWaitForDeviceToRestartTaskLabel
203
+ ) { _ in
204
+ .result(try await self.waitUntilDeviceHasBeenRestarted(deviceID))
205
+ },
206
+
207
+ BlueTask(
208
+ id: BlueSynchronizeAccessTaskId.pushEventLogs,
209
+ label: blueI18n.syncDevicePushEventLogsTaskLabel,
210
+ failable: true
211
+ ) { runner in
212
+ let tokenAuthentication: BlueTokenAuthentication = try runner.getResult(BlueSynchronizeAccessTaskId.getAuthenticationToken)
213
+ let status: BlueSystemStatus = try runner.getResult(BlueSynchronizeAccessTaskId.updateDeviceConfig)
214
+
215
+ return .result(try await self.pushEventLogs(status: status, credential: credential, deviceID: deviceID, with: tokenAuthentication))
216
+ },
217
+
218
+ BlueTask(
219
+ id: BlueSynchronizeAccessTaskId.pushSystemLogs,
220
+ label: blueI18n.syncDevicePushSystemLogsTaskLabel,
221
+ failable: true
222
+ ) { runner in
223
+ let tokenAuthentication: BlueTokenAuthentication = try runner.getResult(BlueSynchronizeAccessTaskId.getAuthenticationToken)
224
+ let status: BlueSystemStatus = try runner.getResult(BlueSynchronizeAccessTaskId.updateDeviceConfig)
225
+
226
+ return .result(try await self.pushSystemLogs(status: status, deviceID: deviceID, with: tokenAuthentication))
227
+ },
228
+
229
+ BlueTask(
230
+ id: BlueSynchronizeAccessTaskId.getBlacklistEntries,
231
+ label: blueI18n.syncDeviceRetrieveBlacklistEntriesTaskLabel,
232
+ failable: true
233
+ ) { runner in
234
+ let tokenAuthentication: BlueTokenAuthentication = try runner.getResult(BlueSynchronizeAccessTaskId.getAuthenticationToken)
235
+
236
+ return .result(try await self.getBlacklistEntries(deviceID, tokenAuthentication))
237
+ },
238
+
239
+ BlueTask(
240
+ id: BlueSynchronizeAccessTaskId.deployBlacklistEntries,
241
+ label: blueI18n.syncDeviceDeployBlacklistEntriesTaskLabel,
242
+ failable: true
243
+ ) { runner in
244
+ let entries: BlueBlacklistEntries? = try runner.getResult(BlueSynchronizeAccessTaskId.getBlacklistEntries)
245
+
246
+ guard let entries = entries else {
247
+ return .resultWithStatus(nil, .failed)
248
+ }
249
+
250
+ return .result(try await self.deployBlacklistEntries(deviceID, entries))
251
+ },
252
+
253
+ BlueTask(
254
+ id: BlueSynchronizeAccessTaskId.getSystemStatus,
255
+ label: blueI18n.syncDeviceRetrieveSystemStatusTaskLabel
256
+ ) { _ in
257
+ .result(try await self.getSystemStatus(deviceID))
258
+ },
259
+
260
+ BlueTask(
261
+ id: BlueSynchronizeAccessTaskId.pushSystemStatus,
262
+ label: blueI18n.syncDevicePushSystemStatusTaskLabel
263
+ ) { runner in
264
+ let tokenAuthentication: BlueTokenAuthentication = try runner.getResult(BlueSynchronizeAccessTaskId.getAuthenticationToken)
265
+ let status: BlueSystemStatus = try runner.getResult(BlueSynchronizeAccessTaskId.getSystemStatus)
266
+
267
+ try await self.pushDeviceSystemStatus(status: status, with: tokenAuthentication)
268
+
269
+ return .result(status)
270
+ }
271
+ ]
152
272
 
153
- var update = BlueSystemUpdate()
154
- update.timeUnix = BlueSystemTimeUnix()
155
- update.timeUnix.epoch = UInt32(Date().timeIntervalSince1970)
273
+ let runner = BlueSerialTaskRunner(tasks)
156
274
 
157
- if let config = config {
158
- update.config = config
275
+ #if os(iOS) || os(watchOS)
276
+ if (showModal == true) {
277
+ try await blueShowSynchronizeAccessDeviceModal(runner)
278
+ } else {
279
+ try await runner.execute(true)
159
280
  }
281
+ #else
282
+ try await runner.execute(true)
283
+ #endif
160
284
 
161
- let updateStatus: BlueSystemStatus = try await blueTerminalRun(
162
- deviceID: deviceID,
163
- timeoutSeconds: 30.0,
164
- action: "UPDATE",
165
- data: update
166
- )
167
-
168
- device.updateInfo(systemStatus: updateStatus)
169
-
170
- await waitUntilDeviceHasBeenRestarted()
171
-
172
- try await pushEventLogs(status: updateStatus, credential: credential, deviceID: deviceID, with: tokenAuthentication)
173
- try await pushSystemLogs(status: updateStatus, deviceID: deviceID, with: tokenAuthentication)
174
- try await deployBlacklistEntries(deviceID: deviceID, with: tokenAuthentication)
175
-
176
- let status: BlueSystemStatus = await getSystemStatus(deviceID) ?? updateStatus
177
-
178
- try await pushDeviceSystemStatus(status: status, with: tokenAuthentication)
285
+ if runner.isSuccessful() {
286
+ return try runner.getResult(BlueSynchronizeAccessTaskId.pushSystemStatus)
287
+ }
179
288
 
180
- return status
289
+ return nil
181
290
  }
182
291
 
183
- @available(macOS 10.15, *)
184
- private func waitUntilDeviceHasBeenRestarted() async {
185
- try? await Task.sleep(nanoseconds: UInt64(blueSecondsToNanoseconds(10)))
292
+ private func updateDevice(_ deviceID: String, _ config: BlueSystemConfig?) async throws -> BlueSystemStatus {
293
+ do {
294
+ var update = BlueSystemUpdate()
295
+ update.timeUnix = BlueSystemTimeUnix()
296
+ update.timeUnix.epoch = UInt32(Date().timeIntervalSince1970)
297
+
298
+ if let config = config {
299
+ update.config = config
300
+ }
301
+
302
+ return try await blueTerminalRun(
303
+ deviceID: deviceID,
304
+ timeoutSeconds: 30.0,
305
+ action: "UPDATE",
306
+ data: update
307
+ )
308
+ } catch {
309
+ throw BlueError(.sdkUpdateDeviceFailed, cause: error)
310
+ }
186
311
  }
187
312
 
188
- @available(macOS 10.15, *)
189
- private func getSystemStatus(_ deviceID: String) async -> BlueSystemStatus? {
190
- return try? await blueTerminalRun(
191
- deviceID: deviceID,
192
- timeoutSeconds: 30.0,
193
- action: "STATUS"
194
- )
313
+ private func getAuthenticationToken(_ credential: BlueAccessCredential) async throws -> BlueTokenAuthentication {
314
+ do {
315
+ return try await sdkService.authenticationTokenService
316
+ .getTokenAuthentication(credential: credential)
317
+ } catch {
318
+ throw BlueError(.sdkGetAuthenticationTokenFailed, cause: error)
319
+ }
320
+ }
321
+
322
+ private func waitUntilDeviceHasBeenRestarted(_ deviceID: String) async throws {
323
+ do {
324
+ try? await Task.sleep(nanoseconds: UInt64(blueSecondsToNanoseconds(30)))
325
+
326
+ if blueGetDevice(deviceID) == nil {
327
+ throw BlueError(.sdkDeviceNotFound)
328
+ }
329
+ } catch {
330
+ throw BlueError(.sdkWaitDeviceToRestartFailed, cause: error)
331
+ }
332
+ }
333
+
334
+ private func getSystemStatus(_ deviceID: String) async throws -> BlueSystemStatus {
335
+ do {
336
+ return try await blueTerminalRun(
337
+ deviceID: deviceID,
338
+ timeoutSeconds: 30.0,
339
+ action: "STATUS"
340
+ )
341
+ } catch {
342
+ throw BlueError(.sdkGetSystemStatusFailed, cause: error)
343
+ }
195
344
  }
196
345
 
197
- @available(macOS 10.15, *)
198
- private func deployBlacklistEntries(deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
346
+ private func getBlacklistEntries(_ deviceID: String, _ tokenAuthentication: BlueTokenAuthentication) async throws -> BlueBlacklistEntries {
199
347
  do {
200
348
  let response = try await sdkService.apiService.getBlacklistEntries(deviceID: deviceID, with: tokenAuthentication, limit: 50).getData()
201
349
 
202
350
  guard let data = Data(base64Encoded: response.blacklistEntries) else {
203
- return
351
+ throw BlueError(.sdkDecodeBase64Failed)
204
352
  }
205
353
 
206
- let entries: BlueBlacklistEntries = try blueDecodeMessage(data)
207
-
354
+ return try blueDecodeMessage(data)
355
+ } catch {
356
+ throw BlueError(.sdkGetBlacklistEntriesFailed, cause: error)
357
+ }
358
+ }
359
+
360
+ private func deployBlacklistEntries(_ deviceID: String, _ entries: BlueBlacklistEntries) async throws {
361
+ do {
208
362
  try await blueTerminalRun(
209
363
  deviceID: deviceID,
210
364
  timeoutSeconds: 30.0,
@@ -248,7 +402,6 @@ public class BlueSynchronizeAccessDeviceCommand: BlueSdkAsyncCommand {
248
402
  }
249
403
  }
250
404
 
251
- @available(macOS 10.15, *)
252
405
  private func pushEventLogs(status: BlueSystemStatus, credential: BlueAccessCredential, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
253
406
  do {
254
407
  guard status.settings.eventLogEntriesCount > 0 else {
@@ -293,7 +446,6 @@ public class BlueSynchronizeAccessDeviceCommand: BlueSdkAsyncCommand {
293
446
  }
294
447
  }
295
448
 
296
- @available(macOS 10.15, *)
297
449
  private func pushSystemLogs(status: BlueSystemStatus, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
298
450
  do {
299
451
  guard status.settings.systemLogEntriesCount > 0 else {
@@ -332,7 +484,7 @@ public class BlueSynchronizeAccessDeviceCommand: BlueSdkAsyncCommand {
332
484
 
333
485
  return logResult.entries.count
334
486
  }
335
-
487
+
336
488
  } catch {
337
489
  throw BlueError(.sdkSystemLogEntriesPushFailed, cause: error)
338
490
  }
@@ -414,8 +566,7 @@ public class BlueClaimAccessDeviceCommand: BlueSdkAsyncCommand {
414
566
  throw BlueError(.sdkUnsupportedPlatform)
415
567
  }
416
568
  }
417
-
418
- @available(macOS 10.15, *)
569
+
419
570
  public func runAsync(credentialID: String, deviceID: String, objectID: String) async throws -> BlueSystemStatus? {
420
571
  guard let _ = blueGetDevice(deviceID) else {
421
572
  throw BlueError(.sdkDeviceNotFound)
@@ -124,6 +124,11 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
124
124
  case sdkDecodeJsonFailed // = -414
125
125
  case sdkFetchDataFailed // = -415
126
126
  case sdkTimeout // = -416
127
+ case sdkGetAuthenticationTokenFailed // = -417
128
+ case sdkUpdateDeviceFailed // = -418
129
+ case sdkGetBlacklistEntriesFailed // = -419
130
+ case sdkGetSystemStatusFailed // = -420
131
+ case sdkWaitDeviceToRestartFailed // = -421
127
132
  case ossMareturnCodeStart // = -1000
128
133
  case ossMareturnCodeEnd // = -1100
129
134
 
@@ -135,6 +140,11 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
135
140
  switch rawValue {
136
141
  case -1100: self = .ossMareturnCodeEnd
137
142
  case -1000: self = .ossMareturnCodeStart
143
+ case -421: self = .sdkWaitDeviceToRestartFailed
144
+ case -420: self = .sdkGetSystemStatusFailed
145
+ case -419: self = .sdkGetBlacklistEntriesFailed
146
+ case -418: self = .sdkUpdateDeviceFailed
147
+ case -417: self = .sdkGetAuthenticationTokenFailed
138
148
  case -416: self = .sdkTimeout
139
149
  case -415: self = .sdkFetchDataFailed
140
150
  case -414: self = .sdkDecodeJsonFailed
@@ -233,6 +243,11 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
233
243
  switch self {
234
244
  case .ossMareturnCodeEnd: return -1100
235
245
  case .ossMareturnCodeStart: return -1000
246
+ case .sdkWaitDeviceToRestartFailed: return -421
247
+ case .sdkGetSystemStatusFailed: return -420
248
+ case .sdkGetBlacklistEntriesFailed: return -419
249
+ case .sdkUpdateDeviceFailed: return -418
250
+ case .sdkGetAuthenticationTokenFailed: return -417
236
251
  case .sdkTimeout: return -416
237
252
  case .sdkFetchDataFailed: return -415
238
253
  case .sdkDecodeJsonFailed: return -414
@@ -3580,6 +3595,11 @@ extension BlueReturnCode: SwiftProtobuf._ProtoNameProviding {
3580
3595
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
3581
3596
  -1100: .same(proto: "OssMAReturnCodeEnd"),
3582
3597
  -1000: .same(proto: "OssMAReturnCodeStart"),
3598
+ -421: .same(proto: "SdkWaitDeviceToRestartFailed"),
3599
+ -420: .same(proto: "SdkGetSystemStatusFailed"),
3600
+ -419: .same(proto: "SdkGetBlacklistEntriesFailed"),
3601
+ -418: .same(proto: "SdkUpdateDeviceFailed"),
3602
+ -417: .same(proto: "SdkGetAuthenticationTokenFailed"),
3583
3603
  -416: .same(proto: "SdkTimeout"),
3584
3604
  -415: .same(proto: "SdkFetchDataFailed"),
3585
3605
  -414: .same(proto: "SdkDecodeJsonFailed"),
@@ -2,20 +2,20 @@
2
2
  import AVFoundation
3
3
  import SwiftUI
4
4
 
5
- private class HostingController: UIHostingController<BlueModalView> {
5
+ private class HostingController: UIHostingController<BlueAccessDeviceModalView> {
6
6
  override var prefersHomeIndicatorAutoHidden: Bool {
7
7
  return true
8
8
  }
9
9
  }
10
10
 
11
11
  /**
12
- * @class BlueModalSession
12
+ * @class BlueAccessDeviceModalSession
13
13
  *
14
14
  * Modal session for processing BlueModal.
15
15
  * BlueModal (sheet) helps people perform a scoped task that’s closely related to their current context.
16
16
  */
17
- internal class BlueModalSession {
18
- private var viewModel = BlueModalViewModel()
17
+ internal class BlueAccessDeviceModalSession {
18
+ private var viewModel = BlueAccessDeviceModalViewModel()
19
19
  private var isInvalidated: Bool = false
20
20
 
21
21
  /// Starts the modal session.
@@ -26,7 +26,7 @@ internal class BlueModalSession {
26
26
  viewModel.message = message ?? ""
27
27
 
28
28
  let hostingController = HostingController(
29
- rootView: BlueModalView(viewModel) { self.invalidate() }
29
+ rootView: BlueAccessDeviceModalView(viewModel) { self.invalidate() }
30
30
  )
31
31
 
32
32
  hostingController.view.backgroundColor = .clear
@@ -7,7 +7,7 @@ internal enum BlueModalStatus {
7
7
  case Failed
8
8
  }
9
9
 
10
- internal class BlueModalViewModel: ObservableObject {
10
+ internal class BlueAccessDeviceModalViewModel: ObservableObject {
11
11
  @Published var title = ""
12
12
  @Published var message = ""
13
13
  @Published var status: BlueModalStatus = .Waiting
@@ -44,8 +44,8 @@ internal class BlueModalViewModel: ObservableObject {
44
44
  }
45
45
  }
46
46
 
47
- internal struct BlueModalView: View {
48
- @ObservedObject private var vm: BlueModalViewModel
47
+ internal struct BlueAccessDeviceModalView: View {
48
+ @ObservedObject private var vm: BlueAccessDeviceModalViewModel
49
49
 
50
50
  internal var height: CGFloat = 350
51
51
  internal var backgroundColor: UIColor = .white
@@ -55,7 +55,7 @@ internal struct BlueModalView: View {
55
55
  private let cornerRadius: CGFloat = 35
56
56
 
57
57
  public init(
58
- _ vm: BlueModalViewModel,
58
+ _ vm: BlueAccessDeviceModalViewModel,
59
59
  _ onDismiss: @escaping () -> Void)
60
60
  {
61
61
  self.vm = vm
@@ -152,37 +152,26 @@ internal struct BlueModalView: View {
152
152
  }
153
153
  }
154
154
 
155
- extension View {
156
- @ViewBuilder
157
- func hidden(_ isHidden: Bool) -> some View {
158
- if isHidden {
159
- self.hidden()
160
- } else {
161
- self
162
- }
163
- }
164
- }
165
-
166
155
  @available(iOS 16.0, *)
167
- struct ContentView_Preview: PreviewProvider {
156
+ struct BlueAccessDeviceModalView_Preview: PreviewProvider {
168
157
  static var previews: some View {
169
- BlueModalView(
170
- BlueModalViewModel(
158
+ BlueAccessDeviceModalView(
159
+ BlueAccessDeviceModalViewModel(
171
160
  title: "Unlocking in Progress",
172
161
  message: "Establishing secure connection..."
173
162
  )
174
163
  ) {}
175
164
 
176
- BlueModalView(
177
- BlueModalViewModel(
165
+ BlueAccessDeviceModalView(
166
+ BlueAccessDeviceModalViewModel(
178
167
  title: "Access Granted",
179
168
  message: "Please proceed.",
180
169
  status: .Success
181
170
  )
182
171
  ) {}
183
172
 
184
- BlueModalView(
185
- BlueModalViewModel(
173
+ BlueAccessDeviceModalView(
174
+ BlueAccessDeviceModalViewModel(
186
175
  title: "Access Denied",
187
176
  message: "Credentials are not valid at this time and/or day of the week.",
188
177
  status: .Failed
@@ -0,0 +1,14 @@
1
+ #if os(iOS) || os(watchOS)
2
+ import SwiftUI
3
+
4
+ extension View {
5
+ @ViewBuilder
6
+ func hidden(_ isHidden: Bool) -> some View {
7
+ if isHidden {
8
+ self.hidden()
9
+ } else {
10
+ self
11
+ }
12
+ }
13
+ }
14
+ #endif