@blueid/access-capacitor 0.75.0 → 0.76.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.
@@ -80,26 +80,34 @@ public struct BlueOssSoCreateMobileCommand: BlueCommand {
80
80
  }
81
81
  }
82
82
 
83
- fileprivate func executeOssSoNfc<ResultType>(settings: BlueOssSoSettings?, successMessage: String, handler: @escaping (_: UnsafeMutablePointer<BlueOssSoStorage_t>) throws -> ResultType) throws -> ResultType {
83
+ fileprivate func executeOssSoNfc<ResultType>(
84
+ settings: BlueOssSoSettings?,
85
+ successMessage: String,
86
+ ignoreErrors: [BlueReturnCode]? = nil,
87
+ handler: @escaping (_: UnsafeMutablePointer<BlueOssSoStorage_t>) throws -> ResultType) throws -> ResultType {
88
+
84
89
  var result: ResultType? = nil
85
90
 
86
91
  let settingsInUse: BlueOssSoSettings = settings ?? blueCreateOssSoDemoSettings()
87
92
 
88
- try blueNfcExecute({ transponderType in
89
- let pStorage = UnsafeMutablePointer<BlueOssSoStorage_t>.allocate(capacity: 1)
90
-
91
- defer {
92
- pStorage.deallocate()
93
- }
94
-
95
- try blueClibFunctionIn(message: settingsInUse, { (dataPtr, dataSize) in
96
- return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
97
- })
98
-
99
- result = try handler(pStorage)
100
-
101
- return successMessage
102
- })
93
+ try blueNfcExecute(
94
+ { transponderType in
95
+ let pStorage = UnsafeMutablePointer<BlueOssSoStorage_t>.allocate(capacity: 1)
96
+
97
+ defer {
98
+ pStorage.deallocate()
99
+ }
100
+
101
+ try blueClibFunctionIn(message: settingsInUse, { (dataPtr, dataSize) in
102
+ return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
103
+ })
104
+
105
+ result = try handler(pStorage)
106
+
107
+ return successMessage
108
+ },
109
+ ignoreErrors: ignoreErrors
110
+ )
103
111
 
104
112
  guard let result = result else {
105
113
  throw BlueError(.invalidState)
@@ -252,8 +260,8 @@ public struct BlueOssSoReadConfigurationCommand: BlueCommand {
252
260
  ))
253
261
  }
254
262
 
255
- public func run(_ settings: BlueOssSoSettings?) throws -> BlueOssSoConfiguration {
256
- return try executeOssSoNfc(settings: settings, successMessage: blueI18n.nfcOssSuccessReadConfigurationMessage, handler: { pStorage in
263
+ public func run(_ settings: BlueOssSoSettings?, ignoreErrors: [BlueReturnCode]? = nil) throws -> BlueOssSoConfiguration {
264
+ return try executeOssSoNfc(settings: settings, successMessage: blueI18n.nfcOssSuccessReadConfigurationMessage, ignoreErrors: ignoreErrors, handler: { pStorage in
257
265
  return try blueClibFunctionOut({ (dataPtr, dataSize) in
258
266
  return blueOssSo_ReadConfiguration_Ext(pStorage, dataPtr, dataSize, BlueOssSoReadWriteFlags_t(rawValue: BlueOssSoReadWriteFlags_All.rawValue))
259
267
  })
@@ -291,7 +299,7 @@ public struct BlueFormatOssSoCredentialCommand: BlueCommand {
291
299
 
292
300
  public func run(organisation: String, siteID: Int) throws {
293
301
  guard let credential = blueGetAccessCredential(organisation: organisation, siteID: siteID, credentialType: .nfcWriter) else {
294
- throw BlueError(.notFound)
302
+ throw BlueError(.sdkCredentialNotFound)
295
303
  }
296
304
 
297
305
  let ossSoSettings = try blueGetOssSoSettings(credentialID: credential.credentialID.id)
@@ -310,12 +318,14 @@ public struct BlueReadOssSoCredentialCommand: BlueCommand {
310
318
 
311
319
  public func run(organisation: String, siteID: Int) throws -> BlueOssSoConfiguration {
312
320
  guard let credential = blueGetAccessCredential(organisation: organisation, siteID: siteID, credentialType: .nfcWriter) else {
313
- throw BlueError(.notFound)
321
+ throw BlueError(.sdkCredentialNotFound)
314
322
  }
315
323
 
316
324
  let ossSoSettings = try blueGetOssSoSettings(credentialID: credential.credentialID.id)
317
325
 
318
- return try BlueOssSoReadConfigurationCommand().run(ossSoSettings)
326
+ return try BlueOssSoReadConfigurationCommand().run(ossSoSettings, ignoreErrors: [
327
+ .notFound
328
+ ])
319
329
  }
320
330
  }
321
331
 
@@ -341,11 +351,11 @@ public class BlueWriteOssSoCredentialCommand: BlueAPIAsyncCommand {
341
351
  /// - returns: A boolean indicating whether a new configuration has been written in the Transponder or not.
342
352
  public func runAsync(credentialID: String, organisation: String, siteID: Int) async throws -> Bool {
343
353
  guard #available(macOS 10.15, *) else {
344
- throw BlueError(.notSupported)
354
+ throw BlueError(.sdkUnsupportedPlatform)
345
355
  }
346
356
 
347
357
  guard let credential = blueGetAccessCredential(organisation: organisation, siteID: siteID, credentialType: .nfcWriter) else {
348
- throw BlueError(.notFound)
358
+ throw BlueError(.sdkCredentialNotFound)
349
359
  }
350
360
 
351
361
  let ossSoSettings = try blueGetOssSoSettings(credentialID: credential.credentialID.id)
@@ -425,11 +435,11 @@ public class BlueRefreshOssSoCredentialCommand: BlueAPIAsyncCommand {
425
435
  /// - returns: The configuration stored in the transponder.
426
436
  public func runAsync(organisation: String, siteID: Int) async throws -> BlueOssSoConfiguration {
427
437
  guard #available(macOS 10.15, *) else {
428
- throw BlueError(.notSupported)
438
+ throw BlueError(.sdkUnsupportedPlatform)
429
439
  }
430
440
 
431
441
  guard let credential = blueGetAccessCredential(organisation: organisation, siteID: siteID, credentialType: .nfcWriter) else {
432
- throw BlueError(.notFound)
442
+ throw BlueError(.sdkCredentialNotFound)
433
443
  }
434
444
 
435
445
  let ossSoSettings = try blueGetOssSoSettings(credentialID: credential.credentialID.id)
@@ -491,13 +501,13 @@ public class BlueRefreshOssSoCredentialsCommand: BlueAPIAsyncCommand {
491
501
  /// - returns: The status of each NFC credential, and in the case of success, the configuration stored in the transponder.
492
502
  public func runAsync() async throws -> BlueRefreshOssSoCredentials {
493
503
  guard #available(macOS 10.15, *) else {
494
- throw BlueError(.notSupported)
504
+ throw BlueError(.sdkUnsupportedPlatform)
495
505
  }
496
506
 
497
507
  let credentials = try await BlueGetAccessCredentialsCommand().runAsync(credentialType: .nfcWriter, includePrivateKey: true).credentials
498
508
 
499
509
  guard !credentials.isEmpty else {
500
- throw BlueError(.notFound)
510
+ throw BlueError(.sdkCredentialNotFound)
501
511
  }
502
512
 
503
513
  var refreshResult = BlueRefreshOssSoCredentials()
@@ -594,11 +604,11 @@ public class BlueRefreshOssSoCredentialsCommand: BlueAPIAsyncCommand {
594
604
 
595
605
  private func blueGetOssSoSettings(credentialID: String) throws -> BlueOssSoSettings {
596
606
  guard let ossSoEntry: BlueOssEntry = try blueAccessOssSettingsKeyChain.getCodableEntry(id: credentialID) else {
597
- throw BlueError(.invalidState)
607
+ throw BlueError(.sdkOssEntryNotFound)
598
608
  }
599
609
 
600
610
  guard let ossSoSettingsData = ossSoEntry.ossSo else {
601
- throw BlueError(.invalidState)
611
+ throw BlueError(.sdkOssSoSettingsNotFound)
602
612
  }
603
613
 
604
614
  return try blueDecodeMessage(ossSoSettingsData)
@@ -10,6 +10,14 @@ private var blueActiveDevice: BlueDevice? = nil
10
10
 
11
11
  public var defaultTimeoutSec: Double = 10
12
12
 
13
+ internal func isActiveDevice(_ device: BlueDevice) -> Bool {
14
+ guard let activeDevice = blueActiveDevice else {
15
+ return false
16
+ }
17
+
18
+ return activeDevice.info.deviceID == device.info.deviceID
19
+ }
20
+
13
21
  internal struct BlueSPTokenEntry: Codable {
14
22
  var credentialID: String
15
23
  var data: Data
@@ -330,7 +338,7 @@ public func blueTerminalRun<HandlerResult>(
330
338
  }
331
339
 
332
340
  guard let device = blueGetDevice(deviceID) else {
333
- return completion(.failure(BlueError(.notFound)))
341
+ return completion(.failure(BlueError(.sdkDeviceNotFound)))
334
342
  }
335
343
 
336
344
  return DispatchQueue.global(qos: .background).async {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "description": "Capacitor JS plugin for the BlueID Access SDK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",