@blueid/access-capacitor 0.80.0 → 0.82.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.
@@ -120,7 +120,7 @@ public struct BlueGetAccessDevicesCommand: BlueCommand {
120
120
  }
121
121
  }
122
122
 
123
- public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
123
+ public class BlueSynchronizeAccessDeviceCommand: BlueAPIAsyncCommand {
124
124
  internal override func runAsync(arg0: Any? = nil, arg1: Any? = nil, arg2: Any? = nil) async throws -> Any? {
125
125
  if #available(macOS 10.15, *) {
126
126
  return try await runAsync(
@@ -429,7 +429,7 @@ public class BlueClaimAccessDeviceCommand: BlueAPIAsyncCommand {
429
429
 
430
430
  try await BlueSynchronizeMobileAccessCommand(self.blueAPI).runAsync(credentialID: credential.credentialID.id)
431
431
 
432
- let status = try await BlueUpdateDeviceConfigurationCommand(self.blueAPI).runAsync(credentialID: credential.credentialID.id, deviceID: deviceID)
432
+ let status = try await BlueSynchronizeAccessDeviceCommand(self.blueAPI).runAsync(credentialID: credential.credentialID.id, deviceID: deviceID)
433
433
 
434
434
  blueFireListeners(fireEvent: .accessDeviceClaimed, data: nil)
435
435
 
@@ -500,9 +500,9 @@ public struct BlueTryAccessDeviceCommand: BlueAsyncCommand {
500
500
  /// A modal view (sheet) is shown in iOS to represent the progress of the command execution.
501
501
  ///
502
502
  /// - parameter deviceID: The Device ID.
503
- /// - throws: Throws an error of type `BlueError(.invalidState)` if the device could not be found.
504
- /// - throws: Throws an error of type `BlueError(.notFound)` if neither an OssSo nor an OssSid token is found.
505
- /// - throws: Throws an error of type `BlueError(.notSuported)` If the macOS version is earlier than 10.15.
503
+ /// - throws: Throws an error of type `BlueError(.sdkDeviceNotFound)` if the device could not be found.
504
+ /// - throws: Throws an error of type `BlueError(.sdkSpTokenNotFound)` if neither an OssSo nor an OssSid token is found.
505
+ /// - throws: Throws an error of type `BlueError(.sdkUnsupportedPlatform)` If the macOS version is earlier than 10.15.
506
506
  public func runAsync(deviceID: String) async throws -> BlueOssAccessResult {
507
507
  guard let device = blueGetDevice(deviceID) else {
508
508
  throw BlueError(.sdkDeviceNotFound)
@@ -150,22 +150,16 @@ internal class BlueSynchronizeMobileAccessCommand: BlueAbstractSynchronizeAccess
150
150
  override func purge(_ credential: BlueAccessCredential) throws {
151
151
  _ = try? blueAccessCredentialsKeyChain.deleteEntry(id: credential.credentialID.id)
152
152
  _ = try? blueAccessAuthenticationTokensKeyChain.deleteEntry(id: credential.credentialID.id)
153
+ _ = try? blueDeleteSpTokens(credential: credential)
153
154
 
154
155
  guard let deviceList = try? BlueGetAccessDevicesCommand().run(credentialID: credential.credentialID.id) else {
155
156
  return
156
157
  }
157
-
158
- purgeSpTokens(credential, deviceList.devices)
158
+
159
159
  purgeTerminalPublicKeys(deviceList.devices)
160
160
  purgeDevicesStorage(credential)
161
161
  }
162
162
 
163
- private func purgeSpTokens(_ credential: BlueAccessCredential, _ devices: [BlueAccessDevice]) {
164
- devices.forEach { device in
165
- _ = try? blueDeleteSpTokens(credential: credential, deviceID: device.deviceID)
166
- }
167
- }
168
-
169
163
  /// Deletes terminal public keys for a given device list.
170
164
  /// The terminal public keys are only removed if there are no BlueSPTokens in use by the device.
171
165
  /// We may have more than one credential that grants access to the same device.
@@ -197,7 +191,6 @@ public class BlueSynchronizeAccessCredentialsCommand: BlueAPIAsyncCommand {
197
191
  }
198
192
 
199
193
  /// Synchronizes all stored credentials.
200
- /// Note: Master credentials are not synced in case of any, as they can only be synced once during the claiming process.
201
194
  ///
202
195
  /// - throws: Throws an error of type `BlueError(.sdkUnsupportedPlatform)` If the macOS version is earlier than 10.15.
203
196
  /// - returns: The exit status (BlueReturnCode) of each credential, and its error description, if any.
@@ -206,8 +199,7 @@ public class BlueSynchronizeAccessCredentialsCommand: BlueAPIAsyncCommand {
206
199
  throw BlueError(.sdkUnsupportedPlatform)
207
200
  }
208
201
 
209
- let credentials = try await BlueGetAccessCredentialsCommand().runAsync().credentials
210
- .filter { $0.credentialType != .master }
202
+ var credentials = try await BlueGetAccessCredentialsCommand().runAsync().credentials
211
203
 
212
204
  if (credentials.isEmpty) {
213
205
  return BlueSynchronizeAccessCredentials()
@@ -77,7 +77,7 @@ public struct BlueCommands {
77
77
  public let synchronizeAccessCredentials = BlueSynchronizeAccessCredentialsCommand()
78
78
  public let getAccessDevices = BlueGetAccessDevicesCommand()
79
79
  public let listAccessDevices = BlueListAccessDevicesCommand()
80
- public let updateDeviceConfiguration = BlueUpdateDeviceConfigurationCommand()
80
+ public let synchronizeAccessDevice = BlueSynchronizeAccessDeviceCommand()
81
81
  public let getAccessObjects = BlueGetAccessObjectsCommand()
82
82
  public let claimAccessDevice = BlueClaimAccessDeviceCommand()
83
83
  public let getWritableAccessCredentials = BlueGetWritableAccessCredentialsCommand()
@@ -66,10 +66,22 @@ internal func blueStoreSpToken(credential: BlueAccessCredential, deviceID: Strin
66
66
  )
67
67
  }
68
68
 
69
- internal func blueDeleteSpTokens(credential: BlueAccessCredential, deviceID: String) throws {
70
- try blueGetSpTokenEntryIds(deviceID: deviceID).forEach{ entryID in
69
+ /// Deletes all SP Tokens for a given credential.
70
+ ///
71
+ /// - parameter credential: The credential.
72
+ /// - throws: An error is thrown if any error occurs during the retrieval of the entry IDs from the KeyChain.
73
+ internal func blueDeleteSpTokens(credential: BlueAccessCredential) throws {
74
+ try blueTerminalRequestDataKeychain.getEntryIds().forEach { entryID in
75
+
71
76
  if let storedEntry = try? blueGetSpTokenEntry(entryID) {
77
+
72
78
  if var spTokenEntries = storedEntry as? [BlueSPTokenEntry] {
79
+
80
+ let matchCredential = spTokenEntries.contains(where: { $0.credentialID == credential.credentialID.id })
81
+ guard matchCredential else {
82
+ return
83
+ }
84
+
73
85
  spTokenEntries.removeAll( where: { $0.credentialID == credential.credentialID.id } )
74
86
 
75
87
  if (spTokenEntries.isEmpty) {
@@ -81,6 +93,7 @@ internal func blueDeleteSpTokens(credential: BlueAccessCredential, deviceID: Str
81
93
  )
82
94
  }
83
95
  }
96
+
84
97
  else if var _ = storedEntry as? Data {
85
98
  _ = try? blueTerminalRequestDataKeychain.deleteEntry(id: entryID)
86
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.80.0",
3
+ "version": "0.82.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",