@blueid/access-capacitor 0.82.0 → 0.84.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.
@@ -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,15 +27,18 @@
29
27
  <key>HeadersPath</key>
30
28
  <string>Headers</string>
31
29
  <key>LibraryIdentifier</key>
32
- <string>ios-arm64</string>
30
+ <string>ios-arm64_x86_64-simulator</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>
36
+ <string>x86_64</string>
38
37
  </array>
39
38
  <key>SupportedPlatform</key>
40
39
  <string>ios</string>
40
+ <key>SupportedPlatformVariant</key>
41
+ <string>simulator</string>
41
42
  </dict>
42
43
  <dict>
43
44
  <key>BinaryPath</key>
@@ -45,16 +46,15 @@
45
46
  <key>HeadersPath</key>
46
47
  <string>Headers</string>
47
48
  <key>LibraryIdentifier</key>
48
- <string>macos-arm64_x86_64</string>
49
+ <string>ios-arm64</string>
49
50
  <key>LibraryPath</key>
50
51
  <string>libCBlueIDAccess.a</string>
51
52
  <key>SupportedArchitectures</key>
52
53
  <array>
53
54
  <string>arm64</string>
54
- <string>x86_64</string>
55
55
  </array>
56
56
  <key>SupportedPlatform</key>
57
- <string>macos</string>
57
+ <string>ios</string>
58
58
  </dict>
59
59
  </array>
60
60
  <key>CFBundlePackageType</key>
@@ -199,16 +199,16 @@ public class BlueSynchronizeAccessCredentialsCommand: BlueAPIAsyncCommand {
199
199
  throw BlueError(.sdkUnsupportedPlatform)
200
200
  }
201
201
 
202
- var credentials = try await BlueGetAccessCredentialsCommand().runAsync().credentials
202
+ let credentials = try await BlueGetAccessCredentialsCommand().runAsync().credentials
203
203
 
204
204
  if (credentials.isEmpty) {
205
205
  return BlueSynchronizeAccessCredentials()
206
206
  }
207
207
 
208
- return await withTaskGroup(of: BlueSynchronizeAccessCredential.self, returning: BlueSynchronizeAccessCredentials.self) { group in
208
+ let result = await withTaskGroup(of: BlueSynchronizeAccessCredential.self, returning: BlueSynchronizeAccessCredentials.self) { group in
209
209
 
210
210
  for credential in credentials {
211
- group.addTask { await self.handleCredential(credential) }
211
+ group.addTask { await self.synchronizeCredential(credential) }
212
212
  }
213
213
 
214
214
  var credentials: [BlueSynchronizeAccessCredential] = []
@@ -219,9 +219,14 @@ public class BlueSynchronizeAccessCredentialsCommand: BlueAPIAsyncCommand {
219
219
 
220
220
  return BlueSynchronizeAccessCredentials(credentials: credentials)
221
221
  }
222
+
223
+ await purgeTokens()
224
+
225
+ return result
222
226
  }
223
227
 
224
- private func handleCredential(_ credential: BlueAccessCredential) async -> BlueSynchronizeAccessCredential {
228
+ /// Synchronize a given credential.
229
+ private func synchronizeCredential(_ credential: BlueAccessCredential) async -> BlueSynchronizeAccessCredential {
225
230
  var resultItem = BlueSynchronizeAccessCredential()
226
231
  resultItem.credentialID.id = credential.credentialID.id
227
232
 
@@ -242,4 +247,40 @@ public class BlueSynchronizeAccessCredentialsCommand: BlueAPIAsyncCommand {
242
247
 
243
248
  return resultItem
244
249
  }
250
+
251
+ /// Purges orphaned tokens.
252
+ private func purgeTokens() async {
253
+ do {
254
+ let credentialIds = try await BlueGetAccessCredentialsCommand().runAsync().credentials.compactMap { $0.credentialID.id }
255
+
256
+ try blueGetSpTokenEntryIds().forEach{ entryID in
257
+ do {
258
+ let storedEntry = try blueGetSpTokenEntry(entryID)
259
+
260
+ if var spTokenEntries = storedEntry as? [BlueSPTokenEntry] {
261
+
262
+ let initialSize = spTokenEntries.count
263
+
264
+ spTokenEntries.removeAll{ !credentialIds.contains($0.credentialID) }
265
+
266
+ if (initialSize != spTokenEntries.count) {
267
+ if (spTokenEntries.isEmpty) {
268
+ _ = try blueTerminalRequestDataKeychain.deleteEntry(id: entryID)
269
+ } else {
270
+ try blueTerminalRequestDataKeychain.storeEntry(
271
+ id: entryID,
272
+ data: JSONEncoder().encode(spTokenEntries)
273
+ )
274
+ }
275
+ }
276
+ }
277
+
278
+ } catch {
279
+ blueLogError(error.localizedDescription)
280
+ }
281
+ }
282
+ } catch {
283
+ blueLogError(error.localizedDescription)
284
+ }
285
+ }
245
286
  }
@@ -40,13 +40,13 @@ internal func blueCreateSignedCommandDemoToken(_ command: String) throws -> Blue
40
40
  return try blueCreateSignedDemoToken(token)
41
41
  }
42
42
 
43
- internal func blueCreateSignedOssSoDemoToken() throws -> BlueSPToken {
43
+ internal func blueCreateSignedOssSoDemoToken(_ credentialID: String? = nil) throws -> BlueSPToken {
44
44
  var token = BlueSPToken()
45
45
  token.signature = Data()
46
46
 
47
47
  let demoConfiguration = blueCreateOssSoDemoConfiguration()
48
48
 
49
- let provisioningData = try blueCommands.ossSoCreateStandardProvisioningData.run("SO12345678", 1)
49
+ let provisioningData = try blueCommands.ossSoCreateStandardProvisioningData.run(credentialID ?? "SO12345678", 1)
50
50
 
51
51
  token.ossSo = try blueCommands.ossSoCreateMobile.run(provisioningData, demoConfiguration)
52
52
 
@@ -101,16 +101,19 @@ internal func blueDeleteSpTokens(credential: BlueAccessCredential) throws {
101
101
  }
102
102
  }
103
103
 
104
- /// Returns all entry IDs for a given device.
104
+ /// Returns all entry IDs for a given device, if any.
105
105
  ///
106
106
  /// - parameter deviceID: The Device ID.
107
107
  /// - throws: An error is thrown if any error occurs during the retrieval of the entry IDs from the KeyChain.
108
- internal func blueGetSpTokenEntryIds(deviceID: String) throws -> [String] {
108
+ internal func blueGetSpTokenEntryIds(deviceID: String? = nil) throws -> [String] {
109
109
  return try blueTerminalRequestDataKeychain.getEntryIds().compactMap{ entryId in
110
- if (entryId.hasPrefix(deviceID)) {
111
- return entryId
110
+ if let deviceID = deviceID {
111
+ if !entryId.hasPrefix(deviceID) {
112
+ return nil
113
+ }
112
114
  }
113
- return nil
115
+
116
+ return entryId
114
117
  }
115
118
  }
116
119
 
@@ -399,6 +402,8 @@ public func blueTerminalRun<HandlerResult>(
399
402
  completion(.success(handlerResult))
400
403
  }
401
404
  } catch let error {
405
+ blueActiveDevice = nil
406
+
402
407
  if !wasConnected && device.isConnected {
403
408
  do {
404
409
  try device.disconnect()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.82.0",
3
+ "version": "0.84.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",