@blueid/access-capacitor 0.88.0 → 0.90.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.
@@ -1,7 +1,7 @@
1
1
  import Foundation
2
2
 
3
3
  public final class BlueError: Error, LocalizedError, Equatable {
4
- public static var timeoutMessage = "A timeout has occurred"
4
+ public static var timeoutMessage = "A timeout has occurred with return code %returnCode%"
5
5
  public static var returnCodeMessage = "Error with return code %returnCode%"
6
6
  public static var unknownErrorMessage = "Unknnown error has ocurred"
7
7
 
@@ -11,10 +11,11 @@ public final class BlueError: Error, LocalizedError, Equatable {
11
11
  private let detail: String?
12
12
 
13
13
  public var errorDescription: String? {
14
- if (returnCode == .timeout) {
15
- return BlueError.timeoutMessage
14
+ var returnCodeStr = "\(returnCode.rawValue) (\(String(describing: returnCode)))"
15
+
16
+ if (returnCode == .timeout || returnCode == .sdkTimeout) {
17
+ return BlueError.timeoutMessage.replacingOccurrences(of: "%returnCode%", with: returnCodeStr)
16
18
  } else {
17
- var returnCodeStr = "\(returnCode.rawValue) (\(String(describing: returnCode)))"
18
19
  if let cause = cause {
19
20
  returnCodeStr += "\nCause: \(cause.localizedDescription)"
20
21
  }
@@ -33,6 +33,22 @@ internal class BlueKeychain {
33
33
  return nil
34
34
  }
35
35
 
36
+ /// Updates an entry with the specified ID using the provided data without purging it beforehand.
37
+ /// If the entry does not exist, a new one is created.
38
+ ///
39
+ /// - parameter id: The ID of the entry to be updated.
40
+ /// - parameter data: The data to update the entry with.
41
+ /// - throws: Throws an error of type `BlueError(.invalidState)` in case the operation does not succeed.
42
+ func updateEntry(id: String, data: Data) throws {
43
+ return try BlueKeychain.storeEntry(attrService: attrService, attrAccessible: attrAccessible, id: id, data: data, purge: false)
44
+ }
45
+
46
+ /// Stores an entry with the specified ID using the provided data.
47
+ /// If the entry already exists, it is first purged.
48
+ ///
49
+ /// - parameter id: The ID of the entry to be updated.
50
+ /// - parameter data: The data to update the entry with.
51
+ /// - throws: Throws an error of type `BlueError(.invalidState)` in case the operation does not succeed.
36
52
  func storeEntry(id: String, data: Data) throws {
37
53
  return try BlueKeychain.storeEntry(attrService: attrService, attrAccessible: attrAccessible, id: id, data: data)
38
54
  }
@@ -138,7 +154,7 @@ internal class BlueKeychain {
138
154
  return try entryIds.compactMap{ try getEntry(attrService: attrService, attrAccessible: attrAccessible, id: $0) }
139
155
  }
140
156
 
141
- static func storeEntry(attrService: String, attrAccessible: String, id: String, data: Data) throws {
157
+ static func storeEntry(attrService: String, attrAccessible: String, id: String, data: Data, purge: Bool? = true) throws {
142
158
  let query: [String: Any] = [
143
159
  kSecClass as String: kSecClassGenericPassword,
144
160
  kSecAttrService as String: attrService,
@@ -147,7 +163,9 @@ internal class BlueKeychain {
147
163
  kSecValueData as String: data,
148
164
  ]
149
165
 
150
- SecItemDelete(query as CFDictionary)
166
+ if (purge != false) {
167
+ SecItemDelete(query as CFDictionary)
168
+ }
151
169
 
152
170
  let status = SecItemUpdate(query as CFDictionary, [kSecValueData as String: data] as CFDictionary)
153
171
 
@@ -170,7 +170,7 @@ internal func blueNfc_Transceive(_ pCommandApdu: UnsafePointer<UInt8>, _ command
170
170
  let waitResponse = waitSemaphore.wait(timeout: DispatchTime.now() + 13.0)
171
171
 
172
172
  if waitResponse != .success {
173
- return blueAsClibReturnCode(.timeout)
173
+ return blueAsClibReturnCode(.sdkTimeout)
174
174
  }
175
175
 
176
176
  do {
@@ -36,7 +36,7 @@ public struct BlueOssSidCreateMobileCommand: BlueCommand {
36
36
 
37
37
  ossSidMobileOutputSizeMutable.pointee = ossSidMobileOutputSize
38
38
 
39
- _ = try blueClibErrorCheck(blueOssSid_GetStorage_Ext(BlueTransponderType_t(UInt32(BlueTransponderType.mobileTransponder.rawValue)), pStorage, nil, 0, ossSidMobileOutputPtr, ossSidMobileOutputSizeMutable))
39
+ _ = try blueClibErrorCheck(blueOssSid_GetStorage_Ext(BlueTransponderType_t(UInt8(BlueTransponderType.mobileTransponder.rawValue)), pStorage, nil, 0, ossSidMobileOutputPtr, ossSidMobileOutputSizeMutable))
40
40
 
41
41
  // Clear configuration as we always want to use the default one for mobile
42
42
  var usedProvisioningData = provisioningData
@@ -64,7 +64,7 @@ fileprivate func executeOssSidNfc<ResultType>(settings: BlueOssSidSettings?, suc
64
64
  }
65
65
 
66
66
  try blueClibFunctionIn(message: settingsInUse, { (dataPtr, dataSize) in
67
- return blueOssSid_GetStorage_Ext(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
67
+ return blueOssSid_GetStorage_Ext(BlueTransponderType_t(UInt8(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
68
68
  })
69
69
 
70
70
  result = try handler(pStorage)
@@ -109,7 +109,7 @@ public struct BlueOssSidGetStorageProfileCommand: BlueCommand {
109
109
  pStorage.deallocate()
110
110
  }
111
111
 
112
- _ = try blueClibErrorCheck(blueOssSid_GetStorage(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, nil, nil, nil))
112
+ _ = try blueClibErrorCheck(blueOssSid_GetStorage(BlueTransponderType_t(UInt8(transponderType.rawValue)), pStorage, nil, nil, nil))
113
113
 
114
114
  if let provisioningConfig = provisioningConfig {
115
115
  return try blueClibFunctionInOut(message: provisioningConfig, { (configDataPtr, configDataSize, dataPtr, dataSize) in
@@ -61,7 +61,7 @@ public struct BlueOssSoCreateMobileCommand: BlueCommand {
61
61
 
62
62
  ossSoMobileOutputSizeMutable.pointee = ossSoMobileOutputSize
63
63
 
64
- _ = try blueClibErrorCheck(blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt32(BlueTransponderType.mobileTransponder.rawValue)), pStorage, nil, 0, ossSoMobileOutputPtr, ossSoMobileOutputSizeMutable))
64
+ _ = try blueClibErrorCheck(blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt8(BlueTransponderType.mobileTransponder.rawValue)), pStorage, nil, 0, ossSoMobileOutputPtr, ossSoMobileOutputSizeMutable))
65
65
 
66
66
  // Clear configuration as we always want to use the default one for mobile
67
67
  var usedProvisioningData = provisioningData
@@ -100,7 +100,7 @@ fileprivate func executeOssSoNfc<ResultType>(
100
100
  }
101
101
 
102
102
  try blueClibFunctionIn(message: settingsInUse, { (dataPtr, dataSize) in
103
- return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
103
+ return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt8(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
104
104
  })
105
105
 
106
106
  result = try handler(pStorage)
@@ -147,7 +147,7 @@ public struct BlueOssSoGetStorageProfileCommand: BlueCommand {
147
147
  pStorage.deallocate()
148
148
  }
149
149
 
150
- _ = try blueClibErrorCheck(blueOssSo_GetStorage(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, nil, nil, nil))
150
+ _ = try blueClibErrorCheck(blueOssSo_GetStorage(BlueTransponderType_t(UInt8(transponderType.rawValue)), pStorage, nil, nil, nil))
151
151
 
152
152
  if let provisioningConfig = provisioningConfig {
153
153
  return try blueClibFunctionInOut(message: provisioningConfig, { (configDataPtr, configDataSize, dataPtr, dataSize) in
@@ -535,7 +535,7 @@ public class BlueRefreshOssSoCredentialsCommand: BlueAPIAsyncCommand {
535
535
  let ossSoSettings = try blueGetOssSoSettings(credentialID: credential.credentialID.id)
536
536
 
537
537
  try blueClibFunctionIn(message: ossSoSettings, { (dataPtr, dataSize) in
538
- return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt32(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
538
+ return blueOssSo_GetStorage_Ext(BlueTransponderType_t(UInt8(transponderType.rawValue)), pStorage, dataPtr, dataSize, nil, nil)
539
539
  })
540
540
 
541
541
  let isProvisioned = blueOssSo_IsProvisioned(pStorage) == BlueReturnCode_Ok
@@ -36,7 +36,7 @@ internal func blueExecuteWithTimeout(_ handler: @escaping () throws -> Void, tim
36
36
  workItem.wait()
37
37
  } else {
38
38
  if workItem.wait(timeout: DispatchTime.now() + timeoutSeconds) == .timedOut {
39
- throw BlueError(.timeout)
39
+ throw BlueError(.sdkTimeout)
40
40
  }
41
41
  }
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.88.0",
3
+ "version": "0.90.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",