@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.
- package/dist/esm/BlueCore_pb.d.ts +64 -0
- package/dist/esm/BlueCore_pb.js +80 -0
- package/dist/esm/BlueCore_pb.js.map +1 -1
- package/dist/plugin.cjs.js +80 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +80 -0
- package/dist/plugin.js.map +1 -1
- package/ios/CBlueIDAccess.xcframework/Info.plist +5 -5
- package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +16 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +16 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +16 -0
- package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +30 -38
- package/ios/Plugin/BlueIDAccessSDK/BlueAccessSync.swift +2 -2
- package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +64 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueDevices.swift +2 -1
- package/ios/Plugin/BlueIDAccessSDK/BlueError.swift +13 -1
- package/ios/Plugin/BlueIDAccessSDK/BlueFetch.swift +40 -13
- package/ios/Plugin/BlueIDAccessSDK/BlueNfc.swift +17 -5
- package/ios/Plugin/BlueIDAccessSDK/BlueOssSo.swift +39 -29
- package/ios/Plugin/BlueIDAccessSDK/BlueTerminal.swift +9 -1
- package/package.json +1 -1
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
<key>HeadersPath</key>
|
|
30
30
|
<string>Headers</string>
|
|
31
31
|
<key>LibraryIdentifier</key>
|
|
32
|
-
<string>
|
|
32
|
+
<string>macos-arm64_x86_64</string>
|
|
33
33
|
<key>LibraryPath</key>
|
|
34
34
|
<string>libCBlueIDAccess.a</string>
|
|
35
35
|
<key>SupportedArchitectures</key>
|
|
36
36
|
<array>
|
|
37
37
|
<string>arm64</string>
|
|
38
|
+
<string>x86_64</string>
|
|
38
39
|
</array>
|
|
39
40
|
<key>SupportedPlatform</key>
|
|
40
|
-
<string>
|
|
41
|
+
<string>macos</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>
|
|
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>
|
|
57
|
+
<string>ios</string>
|
|
58
58
|
</dict>
|
|
59
59
|
</array>
|
|
60
60
|
<key>CFBundlePackageType</key>
|
|
@@ -88,6 +88,22 @@ typedef enum BlueReturnCode {
|
|
|
88
88
|
BlueReturnCode_MifareDesfireCmacNotReceived = -302,
|
|
89
89
|
BlueReturnCode_MifareDesfireCmacNotVerified = -303,
|
|
90
90
|
BlueReturnCode_MifareDesfireNoneOrInvalidAid = -304,
|
|
91
|
+
BlueReturnCode_SdkCredentialNotFound = -400,
|
|
92
|
+
BlueReturnCode_SdkCredentialPrivateKeyNotFound = -401,
|
|
93
|
+
BlueReturnCode_SdkUnsupportedPlatform = -402,
|
|
94
|
+
BlueReturnCode_SdkDeviceNotFound = -403,
|
|
95
|
+
BlueReturnCode_SdkSpTokenNotFound = -404,
|
|
96
|
+
BlueReturnCode_SdkOssEntryNotFound = -405,
|
|
97
|
+
BlueReturnCode_SdkOssSoSettingsNotFound = -406,
|
|
98
|
+
BlueReturnCode_SdkGetSystemConfigFailed = -407,
|
|
99
|
+
BlueReturnCode_SdkEventLogsPushFailed = -408,
|
|
100
|
+
BlueReturnCode_SdkSystemLogEntriesPushFailed = -409,
|
|
101
|
+
BlueReturnCode_SdkBlacklistEntriesDeployFailed = -410,
|
|
102
|
+
BlueReturnCode_SdkDeviceSystemStatusPushFailed = -411,
|
|
103
|
+
BlueReturnCode_SdkNetworkError = -412,
|
|
104
|
+
BlueReturnCode_SdkDecodeBase64Failed = -413,
|
|
105
|
+
BlueReturnCode_SdkDecodeJsonFailed = -414,
|
|
106
|
+
BlueReturnCode_SdkFetchDataFailed = -415,
|
|
91
107
|
BlueReturnCode_OssMAReturnCodeStart = -1000,
|
|
92
108
|
BlueReturnCode_OssMAReturnCodeEnd = -1100
|
|
93
109
|
} BlueReturnCode_t;
|
|
Binary file
|
|
@@ -88,6 +88,22 @@ typedef enum BlueReturnCode {
|
|
|
88
88
|
BlueReturnCode_MifareDesfireCmacNotReceived = -302,
|
|
89
89
|
BlueReturnCode_MifareDesfireCmacNotVerified = -303,
|
|
90
90
|
BlueReturnCode_MifareDesfireNoneOrInvalidAid = -304,
|
|
91
|
+
BlueReturnCode_SdkCredentialNotFound = -400,
|
|
92
|
+
BlueReturnCode_SdkCredentialPrivateKeyNotFound = -401,
|
|
93
|
+
BlueReturnCode_SdkUnsupportedPlatform = -402,
|
|
94
|
+
BlueReturnCode_SdkDeviceNotFound = -403,
|
|
95
|
+
BlueReturnCode_SdkSpTokenNotFound = -404,
|
|
96
|
+
BlueReturnCode_SdkOssEntryNotFound = -405,
|
|
97
|
+
BlueReturnCode_SdkOssSoSettingsNotFound = -406,
|
|
98
|
+
BlueReturnCode_SdkGetSystemConfigFailed = -407,
|
|
99
|
+
BlueReturnCode_SdkEventLogsPushFailed = -408,
|
|
100
|
+
BlueReturnCode_SdkSystemLogEntriesPushFailed = -409,
|
|
101
|
+
BlueReturnCode_SdkBlacklistEntriesDeployFailed = -410,
|
|
102
|
+
BlueReturnCode_SdkDeviceSystemStatusPushFailed = -411,
|
|
103
|
+
BlueReturnCode_SdkNetworkError = -412,
|
|
104
|
+
BlueReturnCode_SdkDecodeBase64Failed = -413,
|
|
105
|
+
BlueReturnCode_SdkDecodeJsonFailed = -414,
|
|
106
|
+
BlueReturnCode_SdkFetchDataFailed = -415,
|
|
91
107
|
BlueReturnCode_OssMAReturnCodeStart = -1000,
|
|
92
108
|
BlueReturnCode_OssMAReturnCodeEnd = -1100
|
|
93
109
|
} BlueReturnCode_t;
|
|
Binary file
|
|
@@ -88,6 +88,22 @@ typedef enum BlueReturnCode {
|
|
|
88
88
|
BlueReturnCode_MifareDesfireCmacNotReceived = -302,
|
|
89
89
|
BlueReturnCode_MifareDesfireCmacNotVerified = -303,
|
|
90
90
|
BlueReturnCode_MifareDesfireNoneOrInvalidAid = -304,
|
|
91
|
+
BlueReturnCode_SdkCredentialNotFound = -400,
|
|
92
|
+
BlueReturnCode_SdkCredentialPrivateKeyNotFound = -401,
|
|
93
|
+
BlueReturnCode_SdkUnsupportedPlatform = -402,
|
|
94
|
+
BlueReturnCode_SdkDeviceNotFound = -403,
|
|
95
|
+
BlueReturnCode_SdkSpTokenNotFound = -404,
|
|
96
|
+
BlueReturnCode_SdkOssEntryNotFound = -405,
|
|
97
|
+
BlueReturnCode_SdkOssSoSettingsNotFound = -406,
|
|
98
|
+
BlueReturnCode_SdkGetSystemConfigFailed = -407,
|
|
99
|
+
BlueReturnCode_SdkEventLogsPushFailed = -408,
|
|
100
|
+
BlueReturnCode_SdkSystemLogEntriesPushFailed = -409,
|
|
101
|
+
BlueReturnCode_SdkBlacklistEntriesDeployFailed = -410,
|
|
102
|
+
BlueReturnCode_SdkDeviceSystemStatusPushFailed = -411,
|
|
103
|
+
BlueReturnCode_SdkNetworkError = -412,
|
|
104
|
+
BlueReturnCode_SdkDecodeBase64Failed = -413,
|
|
105
|
+
BlueReturnCode_SdkDecodeJsonFailed = -414,
|
|
106
|
+
BlueReturnCode_SdkFetchDataFailed = -415,
|
|
91
107
|
BlueReturnCode_OssMAReturnCodeStart = -1000,
|
|
92
108
|
BlueReturnCode_OssMAReturnCodeEnd = -1100
|
|
93
109
|
} BlueReturnCode_t;
|
|
Binary file
|
|
@@ -13,7 +13,7 @@ public class BlueAddAccessCredentialCommand: BlueAPIAsyncCommand {
|
|
|
13
13
|
|
|
14
14
|
public func runAsync(credential: BlueAccessCredential) async throws -> Void {
|
|
15
15
|
guard credential.hasPrivateKey else {
|
|
16
|
-
throw BlueError(.
|
|
16
|
+
throw BlueError(.sdkCredentialPrivateKeyNotFound)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
try blueAccessCredentialsKeyChain.storeEntry(id: credential.credentialID.id, data: credential.jsonUTF8Data())
|
|
@@ -128,24 +128,24 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
128
128
|
deviceID: try blueCastArg(String.self, arg1)
|
|
129
129
|
)
|
|
130
130
|
} else {
|
|
131
|
-
throw BlueError(.
|
|
131
|
+
throw BlueError(.sdkUnsupportedPlatform)
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
@available(macOS 10.15, *)
|
|
136
136
|
public func runAsync(credentialID: String, deviceID: String) async throws -> BlueSystemStatus? {
|
|
137
137
|
guard let device = blueGetDevice(deviceID) else {
|
|
138
|
-
throw BlueError(.
|
|
138
|
+
throw BlueError(.sdkDeviceNotFound)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
guard let credential = blueGetAccessCredential(credentialID: credentialID) else {
|
|
142
|
-
throw BlueError(.
|
|
142
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
let tokenAuthentication = try await BlueAccessAPIHelper(blueAPI!)
|
|
146
146
|
.getTokenAuthentication(credential: credential)
|
|
147
147
|
|
|
148
|
-
let config = await getBlueSystemConfig(deviceID: deviceID, with: tokenAuthentication)
|
|
148
|
+
let config = try await getBlueSystemConfig(deviceID: deviceID, with: tokenAuthentication)
|
|
149
149
|
|
|
150
150
|
var update = BlueSystemUpdate()
|
|
151
151
|
update.timeUnix = BlueSystemTimeUnix()
|
|
@@ -166,13 +166,13 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
166
166
|
|
|
167
167
|
await waitUntilDeviceHasBeenRestarted()
|
|
168
168
|
|
|
169
|
-
await pushEventLogs(status: updateStatus, credential: credential, deviceID: deviceID, with: tokenAuthentication)
|
|
170
|
-
await pushSystemLogs(status: updateStatus, deviceID: deviceID, with: tokenAuthentication)
|
|
171
|
-
await deployBlacklistEntries(deviceID: deviceID, with: tokenAuthentication)
|
|
169
|
+
try await pushEventLogs(status: updateStatus, credential: credential, deviceID: deviceID, with: tokenAuthentication)
|
|
170
|
+
try await pushSystemLogs(status: updateStatus, deviceID: deviceID, with: tokenAuthentication)
|
|
171
|
+
try await deployBlacklistEntries(deviceID: deviceID, with: tokenAuthentication)
|
|
172
172
|
|
|
173
173
|
let status: BlueSystemStatus = await getSystemStatus(deviceID) ?? updateStatus
|
|
174
174
|
|
|
175
|
-
await pushDeviceSystemStatus(status: status, with: tokenAuthentication)
|
|
175
|
+
try await pushDeviceSystemStatus(status: status, with: tokenAuthentication)
|
|
176
176
|
|
|
177
177
|
return status
|
|
178
178
|
}
|
|
@@ -192,7 +192,7 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
@available(macOS 10.15, *)
|
|
195
|
-
private func deployBlacklistEntries(deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async {
|
|
195
|
+
private func deployBlacklistEntries(deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
|
|
196
196
|
do {
|
|
197
197
|
let response = try await blueAPI!.getBlacklistEntries(deviceID: deviceID, with: tokenAuthentication, limit: 50).getData()
|
|
198
198
|
|
|
@@ -209,11 +209,11 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
209
209
|
data: entries
|
|
210
210
|
)
|
|
211
211
|
} catch {
|
|
212
|
-
|
|
212
|
+
throw BlueError(.sdkBlacklistEntriesDeployFailed, cause: error)
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
private func getBlueSystemConfig(deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async -> BlueSystemConfig? {
|
|
216
|
+
private func getBlueSystemConfig(deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws -> BlueSystemConfig? {
|
|
217
217
|
do {
|
|
218
218
|
let result = try await blueAPI!.createDeviceConfiguration(deviceID: deviceID, with: tokenAuthentication).getData()
|
|
219
219
|
|
|
@@ -222,20 +222,18 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
guard let data = Data(base64Encoded: systemConfiguration) else {
|
|
225
|
-
|
|
225
|
+
throw BlueError(.sdkDecodeBase64Failed)
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
let config: BlueSystemConfig = try blueDecodeMessage(data)
|
|
229
229
|
|
|
230
230
|
return config
|
|
231
231
|
} catch {
|
|
232
|
-
|
|
232
|
+
throw BlueError(.sdkGetSystemConfigFailed, cause: error)
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
return nil
|
|
236
234
|
}
|
|
237
235
|
|
|
238
|
-
private func pushDeviceSystemStatus(status: BlueSystemStatus, with tokenAuthentication: BlueTokenAuthentication) async {
|
|
236
|
+
private func pushDeviceSystemStatus(status: BlueSystemStatus, with tokenAuthentication: BlueTokenAuthentication) async throws {
|
|
239
237
|
do {
|
|
240
238
|
let result = try await blueAPI!.updateDeviceSystemStatus(systemStatus: blueEncodeMessage(status).base64EncodedString(), with: tokenAuthentication).getData()
|
|
241
239
|
|
|
@@ -243,19 +241,13 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
243
241
|
blueLogWarn("System status could not be deployed")
|
|
244
242
|
}
|
|
245
243
|
} catch {
|
|
246
|
-
|
|
244
|
+
throw BlueError(.sdkDeviceSystemStatusPushFailed, cause: error)
|
|
247
245
|
}
|
|
248
246
|
}
|
|
249
247
|
|
|
250
248
|
@available(macOS 10.15, *)
|
|
251
|
-
private func pushEventLogs(status: BlueSystemStatus, credential: BlueAccessCredential, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async {
|
|
249
|
+
private func pushEventLogs(status: BlueSystemStatus, credential: BlueAccessCredential, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
|
|
252
250
|
do {
|
|
253
|
-
let deviceList = try BlueGetAccessDevicesCommand().run(credentialID: credential.credentialID.id)
|
|
254
|
-
guard deviceList.devices.first(where: { $0.deviceID == deviceID }) != nil else {
|
|
255
|
-
blueLogWarn("Device could not be found. Event logs have not been deployed")
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
|
|
259
251
|
guard status.settings.eventLogEntriesCount > 0 else {
|
|
260
252
|
blueLogWarn("No event logs to be deployed")
|
|
261
253
|
return
|
|
@@ -302,12 +294,12 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
302
294
|
} while (sent < 100 && offset < status.settings.eventLogEntriesCount)
|
|
303
295
|
|
|
304
296
|
} catch {
|
|
305
|
-
|
|
297
|
+
throw BlueError(.sdkEventLogsPushFailed, cause: error)
|
|
306
298
|
}
|
|
307
299
|
}
|
|
308
300
|
|
|
309
301
|
@available(macOS 10.15, *)
|
|
310
|
-
private func pushSystemLogs(status: BlueSystemStatus, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async {
|
|
302
|
+
private func pushSystemLogs(status: BlueSystemStatus, deviceID: String, with tokenAuthentication: BlueTokenAuthentication) async throws {
|
|
311
303
|
do {
|
|
312
304
|
let limit = 10
|
|
313
305
|
|
|
@@ -353,7 +345,7 @@ public class BlueUpdateDeviceConfigurationCommand: BlueAPIAsyncCommand {
|
|
|
353
345
|
|
|
354
346
|
} while (sent < 50 && sent < status.settings.systemLogEntriesCount)
|
|
355
347
|
} catch {
|
|
356
|
-
|
|
348
|
+
throw BlueError(.sdkSystemLogEntriesPushFailed, cause: error)
|
|
357
349
|
}
|
|
358
350
|
}
|
|
359
351
|
}
|
|
@@ -367,7 +359,7 @@ public class BlueGetAccessObjectsCommand: BlueAPIAsyncCommand {
|
|
|
367
359
|
|
|
368
360
|
public func runAsync(credentialID: String) async throws -> BlueAccessObjectList {
|
|
369
361
|
guard let credential = blueGetAccessCredential(credentialID: credentialID) else {
|
|
370
|
-
throw BlueError(.
|
|
362
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
371
363
|
}
|
|
372
364
|
|
|
373
365
|
let tokenAuthentication = try await BlueAccessAPIHelper(blueAPI!)
|
|
@@ -417,18 +409,18 @@ public class BlueClaimAccessDeviceCommand: BlueAPIAsyncCommand {
|
|
|
417
409
|
objectID: try blueCastArg(String.self, arg2)
|
|
418
410
|
)
|
|
419
411
|
} else {
|
|
420
|
-
throw BlueError(.
|
|
412
|
+
throw BlueError(.sdkUnsupportedPlatform)
|
|
421
413
|
}
|
|
422
414
|
}
|
|
423
415
|
|
|
424
416
|
@available(macOS 10.15, *)
|
|
425
417
|
public func runAsync(credentialID: String, deviceID: String, objectID: String) async throws -> BlueSystemStatus? {
|
|
426
418
|
guard let _ = blueGetDevice(deviceID) else {
|
|
427
|
-
throw BlueError(.
|
|
419
|
+
throw BlueError(.sdkDeviceNotFound)
|
|
428
420
|
}
|
|
429
421
|
|
|
430
422
|
guard let credential = blueGetAccessCredential(credentialID: credentialID) else {
|
|
431
|
-
throw BlueError(.
|
|
423
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
432
424
|
}
|
|
433
425
|
|
|
434
426
|
let tokenAuthentication = try await BlueAccessAPIHelper(blueAPI!)
|
|
@@ -456,7 +448,7 @@ public class BlueGetWritableAccessCredentialsCommand: BlueAPIAsyncCommand {
|
|
|
456
448
|
|
|
457
449
|
public func runAsync(organisation: String, siteID: Int) async throws -> BlueAccessCredentialList {
|
|
458
450
|
guard let credential = blueGetAccessCredential(organisation: organisation, siteID: siteID, credentialType: .nfcWriter) else {
|
|
459
|
-
throw BlueError(.
|
|
451
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
460
452
|
}
|
|
461
453
|
|
|
462
454
|
let tokenAuthentication = try await BlueAccessAPIHelper(blueAPI!)
|
|
@@ -514,23 +506,23 @@ public struct BlueTryAccessDeviceCommand: BlueAsyncCommand {
|
|
|
514
506
|
/// - throws: Throws an error of type `BlueError(.notSuported)` If the macOS version is earlier than 10.15.
|
|
515
507
|
public func runAsync(deviceID: String) async throws -> BlueOssAccessResult {
|
|
516
508
|
guard let device = blueGetDevice(deviceID) else {
|
|
517
|
-
throw BlueError(.
|
|
509
|
+
throw BlueError(.sdkDeviceNotFound)
|
|
518
510
|
}
|
|
519
511
|
|
|
520
512
|
let hasOssSoToken = blueHasSpTokenForAction(device: device, action: "ossSoMobile")
|
|
521
513
|
let hasOssSidToken = blueHasSpTokenForAction(device: device, action: "ossSidMobile")
|
|
522
514
|
|
|
523
515
|
if (!hasOssSoToken && !hasOssSidToken) {
|
|
524
|
-
throw BlueError(.
|
|
516
|
+
throw BlueError(.sdkSpTokenNotFound)
|
|
525
517
|
}
|
|
526
518
|
|
|
527
519
|
let tryOssAccess: () async throws -> BlueOssAccessResult = {
|
|
528
520
|
guard #available(macOS 10.15, *) else {
|
|
529
|
-
throw BlueError(.
|
|
521
|
+
throw BlueError(.sdkUnsupportedPlatform)
|
|
530
522
|
}
|
|
531
523
|
|
|
532
524
|
guard let terminalRun = self.terminalRun else {
|
|
533
|
-
throw BlueError(.
|
|
525
|
+
throw BlueError(.sdkUnsupportedPlatform)
|
|
534
526
|
}
|
|
535
527
|
|
|
536
528
|
if (hasOssSoToken) {
|
|
@@ -541,7 +533,7 @@ public struct BlueTryAccessDeviceCommand: BlueAsyncCommand {
|
|
|
541
533
|
return try await terminalRun(deviceID, defaultTimeoutSec, "ossSidMobile")
|
|
542
534
|
}
|
|
543
535
|
|
|
544
|
-
throw BlueError(.
|
|
536
|
+
throw BlueError(.sdkSpTokenNotFound)
|
|
545
537
|
}
|
|
546
538
|
|
|
547
539
|
#if os(iOS) || os(watchOS)
|
|
@@ -9,7 +9,7 @@ public class BlueSynchronizeAccessCredentialCommand: BlueAPIAsyncCommand {
|
|
|
9
9
|
|
|
10
10
|
public func runAsync(credentialID: String, forceRefresh: Bool? = nil) async throws {
|
|
11
11
|
guard let credential = blueGetAccessCredential(credentialID: credentialID) else {
|
|
12
|
-
throw BlueError(.
|
|
12
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (credential.credentialType == .nfcWriter) {
|
|
@@ -31,7 +31,7 @@ internal class BlueAbstractSynchronizeAccessCommand<T>: BlueAPIAsyncCommand wher
|
|
|
31
31
|
|
|
32
32
|
func runAsync(credentialID: String, forceRefresh: Bool? = nil) async throws -> Void {
|
|
33
33
|
guard let credential = blueGetAccessCredential(credentialID: credentialID) else {
|
|
34
|
-
throw BlueError(.
|
|
34
|
+
throw BlueError(.sdkCredentialNotFound)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
let tokenAuthentication = try await BlueAccessAPIHelper(blueAPI!)
|
|
@@ -107,6 +107,22 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
|
|
|
107
107
|
case mifareDesfireCmacNotReceived // = -302
|
|
108
108
|
case mifareDesfireCmacNotVerified // = -303
|
|
109
109
|
case mifareDesfireNoneOrInvalidAid // = -304
|
|
110
|
+
case sdkCredentialNotFound // = -400
|
|
111
|
+
case sdkCredentialPrivateKeyNotFound // = -401
|
|
112
|
+
case sdkUnsupportedPlatform // = -402
|
|
113
|
+
case sdkDeviceNotFound // = -403
|
|
114
|
+
case sdkSpTokenNotFound // = -404
|
|
115
|
+
case sdkOssEntryNotFound // = -405
|
|
116
|
+
case sdkOssSoSettingsNotFound // = -406
|
|
117
|
+
case sdkGetSystemConfigFailed // = -407
|
|
118
|
+
case sdkEventLogsPushFailed // = -408
|
|
119
|
+
case sdkSystemLogEntriesPushFailed // = -409
|
|
120
|
+
case sdkBlacklistEntriesDeployFailed // = -410
|
|
121
|
+
case sdkDeviceSystemStatusPushFailed // = -411
|
|
122
|
+
case sdkNetworkError // = -412
|
|
123
|
+
case sdkDecodeBase64Failed // = -413
|
|
124
|
+
case sdkDecodeJsonFailed // = -414
|
|
125
|
+
case sdkFetchDataFailed // = -415
|
|
110
126
|
case ossMareturnCodeStart // = -1000
|
|
111
127
|
case ossMareturnCodeEnd // = -1100
|
|
112
128
|
|
|
@@ -118,6 +134,22 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
|
|
|
118
134
|
switch rawValue {
|
|
119
135
|
case -1100: self = .ossMareturnCodeEnd
|
|
120
136
|
case -1000: self = .ossMareturnCodeStart
|
|
137
|
+
case -415: self = .sdkFetchDataFailed
|
|
138
|
+
case -414: self = .sdkDecodeJsonFailed
|
|
139
|
+
case -413: self = .sdkDecodeBase64Failed
|
|
140
|
+
case -412: self = .sdkNetworkError
|
|
141
|
+
case -411: self = .sdkDeviceSystemStatusPushFailed
|
|
142
|
+
case -410: self = .sdkBlacklistEntriesDeployFailed
|
|
143
|
+
case -409: self = .sdkSystemLogEntriesPushFailed
|
|
144
|
+
case -408: self = .sdkEventLogsPushFailed
|
|
145
|
+
case -407: self = .sdkGetSystemConfigFailed
|
|
146
|
+
case -406: self = .sdkOssSoSettingsNotFound
|
|
147
|
+
case -405: self = .sdkOssEntryNotFound
|
|
148
|
+
case -404: self = .sdkSpTokenNotFound
|
|
149
|
+
case -403: self = .sdkDeviceNotFound
|
|
150
|
+
case -402: self = .sdkUnsupportedPlatform
|
|
151
|
+
case -401: self = .sdkCredentialPrivateKeyNotFound
|
|
152
|
+
case -400: self = .sdkCredentialNotFound
|
|
121
153
|
case -304: self = .mifareDesfireNoneOrInvalidAid
|
|
122
154
|
case -303: self = .mifareDesfireCmacNotVerified
|
|
123
155
|
case -302: self = .mifareDesfireCmacNotReceived
|
|
@@ -199,6 +231,22 @@ public enum BlueReturnCode: SwiftProtobuf.Enum {
|
|
|
199
231
|
switch self {
|
|
200
232
|
case .ossMareturnCodeEnd: return -1100
|
|
201
233
|
case .ossMareturnCodeStart: return -1000
|
|
234
|
+
case .sdkFetchDataFailed: return -415
|
|
235
|
+
case .sdkDecodeJsonFailed: return -414
|
|
236
|
+
case .sdkDecodeBase64Failed: return -413
|
|
237
|
+
case .sdkNetworkError: return -412
|
|
238
|
+
case .sdkDeviceSystemStatusPushFailed: return -411
|
|
239
|
+
case .sdkBlacklistEntriesDeployFailed: return -410
|
|
240
|
+
case .sdkSystemLogEntriesPushFailed: return -409
|
|
241
|
+
case .sdkEventLogsPushFailed: return -408
|
|
242
|
+
case .sdkGetSystemConfigFailed: return -407
|
|
243
|
+
case .sdkOssSoSettingsNotFound: return -406
|
|
244
|
+
case .sdkOssEntryNotFound: return -405
|
|
245
|
+
case .sdkSpTokenNotFound: return -404
|
|
246
|
+
case .sdkDeviceNotFound: return -403
|
|
247
|
+
case .sdkUnsupportedPlatform: return -402
|
|
248
|
+
case .sdkCredentialPrivateKeyNotFound: return -401
|
|
249
|
+
case .sdkCredentialNotFound: return -400
|
|
202
250
|
case .mifareDesfireNoneOrInvalidAid: return -304
|
|
203
251
|
case .mifareDesfireCmacNotVerified: return -303
|
|
204
252
|
case .mifareDesfireCmacNotReceived: return -302
|
|
@@ -3488,6 +3536,22 @@ extension BlueReturnCode: SwiftProtobuf._ProtoNameProviding {
|
|
|
3488
3536
|
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
|
3489
3537
|
-1100: .same(proto: "OssMAReturnCodeEnd"),
|
|
3490
3538
|
-1000: .same(proto: "OssMAReturnCodeStart"),
|
|
3539
|
+
-415: .same(proto: "SdkFetchDataFailed"),
|
|
3540
|
+
-414: .same(proto: "SdkDecodeJsonFailed"),
|
|
3541
|
+
-413: .same(proto: "SdkDecodeBase64Failed"),
|
|
3542
|
+
-412: .same(proto: "SdkNetworkError"),
|
|
3543
|
+
-411: .same(proto: "SdkDeviceSystemStatusPushFailed"),
|
|
3544
|
+
-410: .same(proto: "SdkBlacklistEntriesDeployFailed"),
|
|
3545
|
+
-409: .same(proto: "SdkSystemLogEntriesPushFailed"),
|
|
3546
|
+
-408: .same(proto: "SdkEventLogsPushFailed"),
|
|
3547
|
+
-407: .same(proto: "SdkGetSystemConfigFailed"),
|
|
3548
|
+
-406: .same(proto: "SdkOssSoSettingsNotFound"),
|
|
3549
|
+
-405: .same(proto: "SdkOssEntryNotFound"),
|
|
3550
|
+
-404: .same(proto: "SdkSpTokenNotFound"),
|
|
3551
|
+
-403: .same(proto: "SdkDeviceNotFound"),
|
|
3552
|
+
-402: .same(proto: "SdkUnsupportedPlatform"),
|
|
3553
|
+
-401: .same(proto: "SdkCredentialPrivateKeyNotFound"),
|
|
3554
|
+
-400: .same(proto: "SdkCredentialNotFound"),
|
|
3491
3555
|
-304: .same(proto: "MifareDesfireNoneOrInvalidAid"),
|
|
3492
3556
|
-303: .same(proto: "MifareDesfireCmacNotVerified"),
|
|
3493
3557
|
-302: .same(proto: "MifareDesfireCmacNotReceived"),
|
|
@@ -33,7 +33,8 @@ internal func bluePurgeOldDevices() {
|
|
|
33
33
|
var newDevices: [BlueDevice] = []
|
|
34
34
|
|
|
35
35
|
for device in blueDevices {
|
|
36
|
-
|
|
36
|
+
let shouldPurge = now.timeIntervalSince(device.lastSeenAt) >= maxDeviceAgeSeconds && !isActiveDevice(device)
|
|
37
|
+
if (shouldPurge) {
|
|
37
38
|
blueNotifyRemovedDevice(device)
|
|
38
39
|
} else {
|
|
39
40
|
newDevices.append(device)
|
|
@@ -7,11 +7,17 @@ public final class BlueError: Error, LocalizedError, Equatable {
|
|
|
7
7
|
|
|
8
8
|
public let returnCode: BlueReturnCode
|
|
9
9
|
|
|
10
|
+
private let cause: Error?
|
|
11
|
+
|
|
10
12
|
public var errorDescription: String? {
|
|
11
13
|
if (returnCode == .timeout) {
|
|
12
14
|
return BlueError.timeoutMessage
|
|
13
15
|
} else {
|
|
14
|
-
|
|
16
|
+
var returnCodeStr = "\(returnCode.rawValue) (\(String(describing: returnCode)))"
|
|
17
|
+
if let cause = cause {
|
|
18
|
+
returnCodeStr += "\nCause: \(cause.localizedDescription)"
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
return BlueError.returnCodeMessage.replacingOccurrences(of: "%returnCode%", with: returnCodeStr)
|
|
16
22
|
}
|
|
17
23
|
}
|
|
@@ -30,6 +36,12 @@ public final class BlueError: Error, LocalizedError, Equatable {
|
|
|
30
36
|
|
|
31
37
|
public init(_ returnCode: BlueReturnCode) {
|
|
32
38
|
self.returnCode = returnCode
|
|
39
|
+
self.cause = nil
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public init(_ returnCode: BlueReturnCode, cause: Error) {
|
|
43
|
+
self.returnCode = returnCode
|
|
44
|
+
self.cause = cause
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
static public func == (lhs: BlueError, rhs: BlueError) -> Bool {
|
|
@@ -11,10 +11,29 @@ struct BlueFetchConfig {
|
|
|
11
11
|
struct BlueFetchResponse<T> where T: Decodable {
|
|
12
12
|
var statusCode: Int?
|
|
13
13
|
var data: T?
|
|
14
|
+
var rawData: Data? = nil
|
|
14
15
|
|
|
15
16
|
func getData() throws -> T {
|
|
16
17
|
guard let data = data else {
|
|
17
|
-
|
|
18
|
+
let status: String = statusCode?.description ?? "Unknown"
|
|
19
|
+
var description = ""
|
|
20
|
+
|
|
21
|
+
if let rawData = rawData {
|
|
22
|
+
if (!rawData.isEmpty) {
|
|
23
|
+
if let text = String(data: rawData, encoding: .utf8) {
|
|
24
|
+
description = " (\(text))"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw BlueError(
|
|
30
|
+
.sdkFetchDataFailed,
|
|
31
|
+
cause: NSError(
|
|
32
|
+
domain: "BlueID",
|
|
33
|
+
code: BlueReturnCode.sdkFetchDataFailed.rawValue,
|
|
34
|
+
userInfo: [NSLocalizedDescriptionKey: "HTTP status code: \(status)\(description)"]
|
|
35
|
+
)
|
|
36
|
+
)
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
return data
|
|
@@ -47,20 +66,28 @@ class BlueFetch {
|
|
|
47
66
|
var statusCode: Int?
|
|
48
67
|
var decodedData: T?
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if let httpResponse = response as? HTTPURLResponse {
|
|
53
|
-
statusCode = httpResponse.statusCode
|
|
69
|
+
do {
|
|
70
|
+
let (data, response) = try await URLSession.shared.data(for: request)
|
|
54
71
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
if let httpResponse = response as? HTTPURLResponse {
|
|
73
|
+
statusCode = httpResponse.statusCode
|
|
74
|
+
|
|
75
|
+
blueLogDebug("Status code: \(httpResponse.statusCode)")
|
|
76
|
+
blueLogDebug("Data: \(String(describing: String(data: data, encoding: .utf8)))")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (statusCode == 200) {
|
|
80
|
+
do {
|
|
81
|
+
decodedData = try JSONDecoder().decode(T.self, from: data)
|
|
82
|
+
} catch {
|
|
83
|
+
throw BlueError(.sdkDecodeJsonFailed, cause: error)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return BlueFetchResponse(statusCode: statusCode, data: decodedData, rawData: data)
|
|
88
|
+
} catch {
|
|
89
|
+
throw BlueError(.sdkNetworkError, cause: error)
|
|
61
90
|
}
|
|
62
|
-
|
|
63
|
-
return BlueFetchResponse(statusCode: statusCode, data: decodedData)
|
|
64
91
|
}
|
|
65
92
|
|
|
66
93
|
private static func applyConfig(_ request: inout URLRequest, _ config: BlueFetchConfig?) {
|
|
@@ -46,7 +46,7 @@ private final class BlueNfcSessionListener: NSObject, NFCTagReaderSessionDelegat
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throws -> String, timeoutSeconds: Double = 0) throws {
|
|
49
|
+
internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throws -> String, timeoutSeconds: Double = 0, ignoreErrors: [BlueReturnCode]? = nil) throws {
|
|
50
50
|
try blueExecuteWithTimeout({
|
|
51
51
|
let isActive = blueNfcSession != nil
|
|
52
52
|
|
|
@@ -69,8 +69,8 @@ internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throw
|
|
|
69
69
|
throw BlueError(.invalidState)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
session.begin()
|
|
73
72
|
session.alertMessage = blueI18n.nfcWaitMessage
|
|
73
|
+
session.begin()
|
|
74
74
|
|
|
75
75
|
do {
|
|
76
76
|
_ = try blueWaitSignal(group: "nfc", name: "connect")
|
|
@@ -95,13 +95,25 @@ internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throw
|
|
|
95
95
|
|
|
96
96
|
blueNfcSession = nil
|
|
97
97
|
} catch let error {
|
|
98
|
-
var errorMessage = BlueError.unknownErrorMessage
|
|
98
|
+
var errorMessage: String? = BlueError.unknownErrorMessage
|
|
99
99
|
|
|
100
100
|
if (error.localizedDescription != "") {
|
|
101
101
|
errorMessage = error.localizedDescription
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
if let ignoreErrors = ignoreErrors {
|
|
105
|
+
if let blueError = error as? BlueError {
|
|
106
|
+
if (ignoreErrors.contains(blueError.returnCode)) {
|
|
107
|
+
errorMessage = nil
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if let errorMessage = errorMessage {
|
|
113
|
+
session.invalidate(errorMessage: errorMessage)
|
|
114
|
+
} else {
|
|
115
|
+
session.invalidate()
|
|
116
|
+
}
|
|
105
117
|
|
|
106
118
|
blueNfcSession = nil
|
|
107
119
|
|
|
@@ -172,7 +184,7 @@ internal func blueNfc_Transceive(_ pCommandApdu: UnsafePointer<UInt8>, _ command
|
|
|
172
184
|
|
|
173
185
|
#else
|
|
174
186
|
|
|
175
|
-
internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throws -> String, timeoutSeconds: Double = 0) throws {
|
|
187
|
+
internal func blueNfcExecute(_ handler: @escaping (_: BlueTransponderType) throws -> String, timeoutSeconds: Double = 0, ignoreErrors: [BlueReturnCode]? = nil) throws {
|
|
176
188
|
throw BlueError(.notSupported)
|
|
177
189
|
}
|
|
178
190
|
|