@blueid/access-capacitor 0.98.0 → 0.99.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.
Files changed (26) hide show
  1. package/dist/esm/BlueCore_pb.d.ts +28 -7
  2. package/dist/esm/BlueCore_pb.js +25 -3
  3. package/dist/esm/BlueCore_pb.js.map +1 -1
  4. package/dist/plugin.cjs.js +26 -3
  5. package/dist/plugin.cjs.js.map +1 -1
  6. package/dist/plugin.js +26 -3
  7. package/dist/plugin.js.map +1 -1
  8. package/ios/CBlueIDAccess.xcframework/Info.plist +5 -5
  9. package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +29 -15
  10. package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/oss/BlueOss.h +1 -1
  11. package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
  12. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +29 -15
  13. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/oss/BlueOss.h +1 -1
  14. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
  15. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +29 -15
  16. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/oss/BlueOss.h +1 -1
  17. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
  18. package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +28 -10
  19. package/ios/Plugin/BlueIDAccessSDK/BlueAccessSync.swift +2 -2
  20. package/ios/Plugin/BlueIDAccessSDK/BlueAccessSyncScheduler.swift +25 -7
  21. package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +72 -10
  22. package/ios/Plugin/BlueIDAccessSDK/BlueDemoData.swift +9 -2
  23. package/ios/Plugin/BlueIDAccessSDK/BlueOssSo.swift +1 -1
  24. package/ios/Plugin/BlueIDAccessSDK/BlueTerminal.swift +11 -1
  25. package/ios/Plugin/BlueIDAccessSDK/Extensions.swift +12 -0
  26. package/package.json +1 -1
@@ -456,12 +456,15 @@ public enum BlueCredentialType: SwiftProtobuf.Enum {
456
456
  /// Maintenance can open and update all locks within the site
457
457
  case maintenance // = 2
458
458
 
459
- /// Master can open all locks within the given site and requires no refresh
459
+ /// Master can open all locks within the given site
460
460
  case master // = 3
461
461
 
462
462
  /// Nfc writer allows to write any credential within this site on cards & fobs
463
463
  case nfcWriter // = 4
464
464
 
465
+ /// Emergency can open all locks within given site, requires no refresh and has no validity
466
+ case emergency // = 5
467
+
465
468
  public init() {
466
469
  self = .regular
467
470
  }
@@ -472,6 +475,7 @@ public enum BlueCredentialType: SwiftProtobuf.Enum {
472
475
  case 2: self = .maintenance
473
476
  case 3: self = .master
474
477
  case 4: self = .nfcWriter
478
+ case 5: self = .emergency
475
479
  default: return nil
476
480
  }
477
481
  }
@@ -482,6 +486,7 @@ public enum BlueCredentialType: SwiftProtobuf.Enum {
482
486
  case .maintenance: return 2
483
487
  case .master: return 3
484
488
  case .nfcWriter: return 4
489
+ case .emergency: return 5
485
490
  }
486
491
  }
487
492
 
@@ -961,6 +966,37 @@ extension BlueOssSoCredentialTypeOssCredential: CaseIterable {
961
966
 
962
967
  #endif // swift(>=4.2)
963
968
 
969
+ public enum BlueOssSoDoorGroupId: SwiftProtobuf.Enum {
970
+ public typealias RawValue = Int
971
+ case masterGroupID // = 0
972
+
973
+ public init() {
974
+ self = .masterGroupID
975
+ }
976
+
977
+ public init?(rawValue: Int) {
978
+ switch rawValue {
979
+ case 0: self = .masterGroupID
980
+ default: return nil
981
+ }
982
+ }
983
+
984
+ public var rawValue: Int {
985
+ switch self {
986
+ case .masterGroupID: return 0
987
+ }
988
+ }
989
+
990
+ }
991
+
992
+ #if swift(>=4.2)
993
+
994
+ extension BlueOssSoDoorGroupId: CaseIterable {
995
+ // Support synthesized by the compiler.
996
+ }
997
+
998
+ #endif // swift(>=4.2)
999
+
964
1000
  public enum BlueOssSoDoorInfoAccessBy: SwiftProtobuf.Enum {
965
1001
  public typealias RawValue = Int
966
1002
  case doorGroupID // = 0
@@ -1786,7 +1822,7 @@ public struct BlueOssAccessResult {
1786
1822
  /// Clears the value of `accessGranted`. Subsequent reads from it will return its default value.
1787
1823
  public mutating func clearAccessGranted() {self._accessGranted = nil}
1788
1824
 
1789
- /// The final access type
1825
+ /// The final access type that was used if access was granted
1790
1826
  public var accessType: BlueAccessType {
1791
1827
  get {return _accessType ?? .defaultTime}
1792
1828
  set {_accessType = newValue}
@@ -1796,8 +1832,18 @@ public struct BlueOssAccessResult {
1796
1832
  /// Clears the value of `accessType`. Subsequent reads from it will return its default value.
1797
1833
  public mutating func clearAccessType() {self._accessType = nil}
1798
1834
 
1799
- /// If access type is a toggle then this specifies the time it should lock
1800
- /// again
1835
+ /// Additional access info if was granted, depends on device
1836
+ /// For locks for example this would contain the BlueLockState
1837
+ public var accessInfo: UInt32 {
1838
+ get {return _accessInfo ?? 0}
1839
+ set {_accessInfo = newValue}
1840
+ }
1841
+ /// Returns true if `accessInfo` has been explicitly set.
1842
+ public var hasAccessInfo: Bool {return self._accessInfo != nil}
1843
+ /// Clears the value of `accessInfo`. Subsequent reads from it will return its default value.
1844
+ public mutating func clearAccessInfo() {self._accessInfo = nil}
1845
+
1846
+ /// Defines when the used schedule actually ends if any if access was granted
1801
1847
  public var scheduleEndTime: BlueLocalTimestamp {
1802
1848
  get {return _scheduleEndTime ?? BlueLocalTimestamp()}
1803
1849
  set {_scheduleEndTime = newValue}
@@ -1823,6 +1869,7 @@ public struct BlueOssAccessResult {
1823
1869
 
1824
1870
  fileprivate var _accessGranted: Bool? = nil
1825
1871
  fileprivate var _accessType: BlueAccessType? = nil
1872
+ fileprivate var _accessInfo: UInt32? = nil
1826
1873
  fileprivate var _scheduleEndTime: BlueLocalTimestamp? = nil
1827
1874
  fileprivate var _scheduleMissmatch: Bool? = nil
1828
1875
  }
@@ -3528,6 +3575,7 @@ extension BlueEventInfoSystem: @unchecked Sendable {}
3528
3575
  extension BlueEventInfoAccess: @unchecked Sendable {}
3529
3576
  extension BlueOssCredentialTypeSource: @unchecked Sendable {}
3530
3577
  extension BlueOssSoCredentialTypeOssCredential: @unchecked Sendable {}
3578
+ extension BlueOssSoDoorGroupId: @unchecked Sendable {}
3531
3579
  extension BlueOssSoDoorInfoAccessBy: @unchecked Sendable {}
3532
3580
  extension BlueOssSoFileId: @unchecked Sendable {}
3533
3581
  extension BlueSharedDemoData: @unchecked Sendable {}
@@ -3722,6 +3770,7 @@ extension BlueCredentialType: SwiftProtobuf._ProtoNameProviding {
3722
3770
  2: .same(proto: "Maintenance"),
3723
3771
  3: .same(proto: "Master"),
3724
3772
  4: .same(proto: "NfcWriter"),
3773
+ 5: .same(proto: "Emergency"),
3725
3774
  ]
3726
3775
  }
3727
3776
 
@@ -3826,6 +3875,12 @@ extension BlueOssSoCredentialTypeOssCredential: SwiftProtobuf._ProtoNameProvidin
3826
3875
  ]
3827
3876
  }
3828
3877
 
3878
+ extension BlueOssSoDoorGroupId: SwiftProtobuf._ProtoNameProviding {
3879
+ public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
3880
+ 0: .same(proto: "MasterGroupId"),
3881
+ ]
3882
+ }
3883
+
3829
3884
  extension BlueOssSoDoorInfoAccessBy: SwiftProtobuf._ProtoNameProviding {
3830
3885
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
3831
3886
  0: .same(proto: "DoorGroupId"),
@@ -4766,13 +4821,15 @@ extension BlueOssAccessResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl
4766
4821
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
4767
4822
  1: .same(proto: "accessGranted"),
4768
4823
  2: .same(proto: "accessType"),
4769
- 3: .same(proto: "scheduleEndTime"),
4770
- 4: .same(proto: "scheduleMissmatch"),
4824
+ 3: .same(proto: "accessInfo"),
4825
+ 4: .same(proto: "scheduleEndTime"),
4826
+ 5: .same(proto: "scheduleMissmatch"),
4771
4827
  ]
4772
4828
 
4773
4829
  public var isInitialized: Bool {
4774
4830
  if self._accessGranted == nil {return false}
4775
4831
  if self._accessType == nil {return false}
4832
+ if self._accessInfo == nil {return false}
4776
4833
  if self._scheduleEndTime == nil {return false}
4777
4834
  if self._scheduleMissmatch == nil {return false}
4778
4835
  if let v = self._scheduleEndTime, !v.isInitialized {return false}
@@ -4787,8 +4844,9 @@ extension BlueOssAccessResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl
4787
4844
  switch fieldNumber {
4788
4845
  case 1: try { try decoder.decodeSingularBoolField(value: &self._accessGranted) }()
4789
4846
  case 2: try { try decoder.decodeSingularEnumField(value: &self._accessType) }()
4790
- case 3: try { try decoder.decodeSingularMessageField(value: &self._scheduleEndTime) }()
4791
- case 4: try { try decoder.decodeSingularBoolField(value: &self._scheduleMissmatch) }()
4847
+ case 3: try { try decoder.decodeSingularUInt32Field(value: &self._accessInfo) }()
4848
+ case 4: try { try decoder.decodeSingularMessageField(value: &self._scheduleEndTime) }()
4849
+ case 5: try { try decoder.decodeSingularBoolField(value: &self._scheduleMissmatch) }()
4792
4850
  default: break
4793
4851
  }
4794
4852
  }
@@ -4805,11 +4863,14 @@ extension BlueOssAccessResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl
4805
4863
  try { if let v = self._accessType {
4806
4864
  try visitor.visitSingularEnumField(value: v, fieldNumber: 2)
4807
4865
  } }()
4866
+ try { if let v = self._accessInfo {
4867
+ try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
4868
+ } }()
4808
4869
  try { if let v = self._scheduleEndTime {
4809
- try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
4870
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
4810
4871
  } }()
4811
4872
  try { if let v = self._scheduleMissmatch {
4812
- try visitor.visitSingularBoolField(value: v, fieldNumber: 4)
4873
+ try visitor.visitSingularBoolField(value: v, fieldNumber: 5)
4813
4874
  } }()
4814
4875
  try unknownFields.traverse(visitor: &visitor)
4815
4876
  }
@@ -4817,6 +4878,7 @@ extension BlueOssAccessResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl
4817
4878
  public static func ==(lhs: BlueOssAccessResult, rhs: BlueOssAccessResult) -> Bool {
4818
4879
  if lhs._accessGranted != rhs._accessGranted {return false}
4819
4880
  if lhs._accessType != rhs._accessType {return false}
4881
+ if lhs._accessInfo != rhs._accessInfo {return false}
4820
4882
  if lhs._scheduleEndTime != rhs._scheduleEndTime {return false}
4821
4883
  if lhs._scheduleMissmatch != rhs._scheduleMissmatch {return false}
4822
4884
  if lhs.unknownFields != rhs.unknownFields {return false}
@@ -3,13 +3,16 @@ import Foundation
3
3
 
4
4
  internal let blueDemoData = BlueSharedDemoData()
5
5
 
6
- public func blueCreateAccessCredentialDemo() -> BlueAccessCredential {
6
+ public func blueCreateAccessCredentialDemo(
7
+ id: String? = nil,
8
+ validFrom: BlueLocalTimestamp? = nil
9
+ ) -> BlueAccessCredential {
7
10
  var credential = BlueAccessCredential()
8
11
  credential.name = "Someone's iPhone"
9
12
  credential.siteName = "Somewhere"
10
13
  credential.siteID = 1
11
14
  credential.organisation = "655398ee2b26344d565e6123"
12
- credential.credentialID.id = "8M-1xA3oze"
15
+ credential.credentialID.id = id ?? "8M-1xA3oze"
13
16
  credential.credentialType = .maintenance
14
17
  credential.privateKey = Data([
15
18
  48,129,135,2,1,0,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,
@@ -21,6 +24,10 @@ public func blueCreateAccessCredentialDemo() -> BlueAccessCredential {
21
24
  21,16,242,30,21,101,248,90,139,31,61,150,198,4,196,146,96,174,
22
25
  92,230,194,140,79,9
23
26
  ])
27
+
28
+ if let validFrom = validFrom {
29
+ credential.validFrom = validFrom
30
+ }
24
31
 
25
32
  return credential
26
33
  }
@@ -511,7 +511,7 @@ public class BlueRefreshOssSoCredentialsCommand: BlueSdkAsyncCommand {
511
511
  throw BlueError(.sdkUnsupportedPlatform)
512
512
  }
513
513
 
514
- let credentials = try await BlueGetAccessCredentialsCommand().runAsync(credentialType: .nfcWriter, includePrivateKey: true).credentials
514
+ let credentials = try BlueGetAccessCredentialsCommand().run(credentialType: .nfcWriter, includePrivateKey: true).credentials
515
515
 
516
516
  guard !credentials.isEmpty else {
517
517
  throw BlueError(.sdkCredentialNotFound)
@@ -139,13 +139,23 @@ internal func blueGetSpTokenEntry(_ entryID: String) throws -> Any? {
139
139
  }
140
140
 
141
141
  /// Returns a BlueSPToken with compatibility with previous versions of the SDK.
142
- /// In case the SDK is already storing tokens as an array of BlueSPTokenEntry, then the first BlueSPToken will be returned.
142
+ /// In case the SDK is already storing tokens as an array of BlueSPTokenEntry, then SDK tries to return the first valid BlueSPToken.
143
143
  /// - parameter entryID: The KeyChain Entry ID.
144
144
  /// - throws: An error is thrown if any error occurs during the retrieval of the entry from the KeyChain.
145
145
  /// - throws: An error is thrown if any error occurs when decoding the token Data into a BlueSPToken.
146
146
  internal func blueGetSpToken(_ entryID: String) throws -> BlueSPToken? {
147
147
  if let storedEntry = try blueGetSpTokenEntry(entryID) {
148
148
  if let spTokenEntries = storedEntry as? [BlueSPTokenEntry] {
149
+
150
+ for spTokenEntry in spTokenEntries {
151
+ if let credential = blueGetAccessCredential(credentialID: spTokenEntry.credentialID) {
152
+
153
+ if (credential.checkValidityStart()) {
154
+ return try blueDecodeMessage(spTokenEntry.data)
155
+ }
156
+ }
157
+ }
158
+
149
159
  if let spTokenEntry = spTokenEntries.first {
150
160
  return try blueDecodeMessage(spTokenEntry.data)
151
161
  }
@@ -140,6 +140,18 @@ extension BlueAccessCredential: Decodable {
140
140
  }
141
141
  }
142
142
 
143
+ public func checkValidityStart() -> Bool {
144
+ if self.hasValidFrom {
145
+ if let validFrom = self.validFrom.toDate() {
146
+ if validFrom > Date() {
147
+ return false
148
+ }
149
+ }
150
+ }
151
+
152
+ return true
153
+ }
154
+
143
155
  enum CodingKeys: String, CodingKey {
144
156
  case name
145
157
  case description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.98.0",
3
+ "version": "0.99.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",