@capgo/capacitor-wifi 8.4.1 → 8.5.0-beta.pr20.12.1

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 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Network security types\n *\n * @since 7.0.0\n */\nexport var NetworkSecurityType;\n(function (NetworkSecurityType) {\n /**\n * Open network with no security\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"OPEN\"] = 0] = \"OPEN\";\n /**\n * WEP security\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WEP\"] = 1] = \"WEP\";\n /**\n * WPA/WPA2 Personal (PSK)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA2_PSK\"] = 2] = \"WPA2_PSK\";\n /**\n * WPA/WPA2/WPA3 Enterprise (EAP)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"EAP\"] = 3] = \"EAP\";\n /**\n * WPA3 Personal (SAE)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"SAE\"] = 4] = \"SAE\";\n /**\n * WPA3 Enterprise\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA3_ENTERPRISE\"] = 5] = \"WPA3_ENTERPRISE\";\n /**\n * WPA3 Enterprise 192-bit mode\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA3_ENTERPRISE_192_BIT\"] = 6] = \"WPA3_ENTERPRISE_192_BIT\";\n /**\n * Passpoint network\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"PASSPOINT\"] = 7] = \"PASSPOINT\";\n /**\n * Enhanced Open (OWE)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"OWE\"] = 8] = \"OWE\";\n /**\n * WAPI PSK\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WAPI_PSK\"] = 9] = \"WAPI_PSK\";\n /**\n * WAPI Certificate\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WAPI_CERT\"] = 10] = \"WAPI_CERT\";\n})(NetworkSecurityType || (NetworkSecurityType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorWifi = registerPlugin('CapacitorWifi', {\n web: () => import('./web').then((m) => new m.CapacitorWifiWeb()),\n});\nexport * from './definitions';\nexport { CapacitorWifi };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorWifiWeb extends WebPlugin {\n async addNetwork(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async connect(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async disconnect(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getAvailableNetworks() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getIpAddress() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getRssi() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getSsid() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getWifiInfo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n async startScan() {\n throw this.unimplemented('Not implemented on web.');\n }\n async checkPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestPermissions(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async isNetworkSaved(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async shareNetwork(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: '1.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["NetworkSecurityType","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,mBAAmB,EAAE;IAChC;IACA;IACA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MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;IACnC,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Stable error codes returned by {@link CapacitorWifiPlugin.connect} on failure.\n * Specific codes are returned only when the native platform explicitly provides that reason.\n * Otherwise the plugin returns {@link WifiConnectionErrorCode.CONNECTION_FAILED}.\n *\n * @since 8.5.0\n */\nexport var WifiConnectionErrorCode;\n(function (WifiConnectionErrorCode) {\n /**\n * The SSID, password format, security configuration, timeout, or native request parameters are invalid.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"INVALID_CONFIGURATION\"] = \"INVALID_CONFIGURATION\";\n /**\n * A required permission or authorization is missing or was denied.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /**\n * Wi-Fi is disabled and the connection cannot be started.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"WIFI_DISABLED\"] = \"WIFI_DISABLED\";\n /**\n * The native API explicitly reports that the user rejected the connection request.\n * Available on iOS; on Android only when the OS reports user rejection (API 36+).\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"USER_DENIED\"] = \"USER_DENIED\";\n /**\n * The native API explicitly reports an authentication failure.\n * Not reliably available on Android API 29–33.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"AUTHENTICATION_FAILED\"] = \"AUTHENTICATION_FAILED\";\n /**\n * The native API explicitly reports that the requested access point was not found.\n * Not reliably available on Android API 29–33.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"NETWORK_NOT_FOUND\"] = \"NETWORK_NOT_FOUND\";\n /**\n * The plugin timeout expired before the requested network was confirmed as connected.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"CONNECTION_TIMEOUT\"] = \"CONNECTION_TIMEOUT\";\n /**\n * The connection failed, but the platform did not provide a reliable detailed reason.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"CONNECTION_FAILED\"] = \"CONNECTION_FAILED\";\n /**\n * Another Wi-Fi connection attempt is already active.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"CONNECTION_IN_PROGRESS\"] = \"CONNECTION_IN_PROGRESS\";\n /**\n * An unexpected plugin or native error occurred.\n *\n * @since 8.5.0\n */\n WifiConnectionErrorCode[\"UNKNOWN\"] = \"UNKNOWN\";\n})(WifiConnectionErrorCode || (WifiConnectionErrorCode = {}));\n/**\n * Network security types\n *\n * @since 7.0.0\n */\nexport var NetworkSecurityType;\n(function (NetworkSecurityType) {\n /**\n * Open network with no security\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"OPEN\"] = 0] = \"OPEN\";\n /**\n * WEP security\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WEP\"] = 1] = \"WEP\";\n /**\n * WPA/WPA2 Personal (PSK)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA2_PSK\"] = 2] = \"WPA2_PSK\";\n /**\n * WPA/WPA2/WPA3 Enterprise (EAP)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"EAP\"] = 3] = \"EAP\";\n /**\n * WPA3 Personal (SAE)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"SAE\"] = 4] = \"SAE\";\n /**\n * WPA3 Enterprise\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA3_ENTERPRISE\"] = 5] = \"WPA3_ENTERPRISE\";\n /**\n * WPA3 Enterprise 192-bit mode\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WPA3_ENTERPRISE_192_BIT\"] = 6] = \"WPA3_ENTERPRISE_192_BIT\";\n /**\n * Passpoint network\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"PASSPOINT\"] = 7] = \"PASSPOINT\";\n /**\n * Enhanced Open (OWE)\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"OWE\"] = 8] = \"OWE\";\n /**\n * WAPI PSK\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WAPI_PSK\"] = 9] = \"WAPI_PSK\";\n /**\n * WAPI Certificate\n *\n * @since 7.0.0\n */\n NetworkSecurityType[NetworkSecurityType[\"WAPI_CERT\"] = 10] = \"WAPI_CERT\";\n})(NetworkSecurityType || (NetworkSecurityType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorWifi = registerPlugin('CapacitorWifi', {\n web: () => import('./web').then((m) => new m.CapacitorWifiWeb()),\n});\nexport * from './definitions';\nexport { CapacitorWifi };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorWifiWeb extends WebPlugin {\n async addNetwork(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async connect(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async disconnect(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getAvailableNetworks() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getIpAddress() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getRssi() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getSsid() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getWifiInfo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n async startScan() {\n throw this.unimplemented('Not implemented on web.');\n }\n async checkPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestPermissions(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async isNetworkSaved(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async shareNetwork(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: '1.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["WifiConnectionErrorCode","NetworkSecurityType","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,uBAAuB,EAAE;IACpC;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,uBAAuB,CAAC,GAAG,uBAAuB;IAC9E;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;IACtE;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,eAAe,CAAC,GAAG,eAAe;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,aAAa,CAAC,GAAG,aAAa;IAC1D;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,uBAAuB,CAAC,GAAG,uBAAuB;IAC9E;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;IACtE;IACA;IACA;IACA;IACA;IACA,IAAI,uBAAuB,CAAC,oB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,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;IACnC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ import CoreLocation
5
5
 
6
6
  @objc(CapacitorWifiPlugin)
7
7
  public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
8
- private let pluginVersion: String = "8.4.1"
8
+ private let pluginVersion: String = "8.5.0"
9
9
  public let identifier = "CapacitorWifiPlugin"
10
10
  public let jsName = "CapacitorWifi"
11
11
  public let pluginMethods: [CAPPluginMethod] = [
@@ -29,6 +29,11 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
29
29
  private var hotspotManager: NEHotspotConfigurationManager?
30
30
  private var locationManager: CLLocationManager?
31
31
  private var permissionCalls: [CAPPluginCall] = []
32
+ private let connectLock = NSLock()
33
+ private var connectInProgress = false
34
+ private var connectGeneration = 0
35
+ private let defaultConnectTimeoutMs: Double = 30000
36
+ private let ssidVerifyPollSeconds: TimeInterval = 0.5
32
37
 
33
38
  override public func load() {
34
39
  hotspotManager = NEHotspotConfigurationManager.shared
@@ -63,12 +68,67 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
63
68
  }
64
69
 
65
70
  @objc func connect(_ call: CAPPluginCall) {
66
- guard let ssid = call.getString("ssid") else {
67
- call.reject("SSID is required")
71
+ connectLock.lock()
72
+ if connectInProgress {
73
+ connectLock.unlock()
74
+ rejectConnect(
75
+ call,
76
+ code: "CONNECTION_IN_PROGRESS",
77
+ message: "Another Wi-Fi connection attempt is already in progress.",
78
+ stage: "request",
79
+ nativeCode: nil,
80
+ nativeMessage: nil,
81
+ error: nil
82
+ )
83
+ return
84
+ }
85
+ connectInProgress = true
86
+ connectGeneration += 1
87
+ let generation = connectGeneration
88
+ connectLock.unlock()
89
+
90
+ guard let ssid = call.getString("ssid"), !ssid.isEmpty else {
91
+ finishConnectAttempt(generation)
92
+ rejectConnect(
93
+ call,
94
+ code: "INVALID_CONFIGURATION",
95
+ message: "SSID is required.",
96
+ stage: "validation",
97
+ nativeCode: nil,
98
+ nativeMessage: nil,
99
+ error: nil
100
+ )
101
+ return
102
+ }
103
+
104
+ guard let timeoutMs = resolveTimeoutMs(call) else {
105
+ finishConnectAttempt(generation)
106
+ rejectConnect(
107
+ call,
108
+ code: "INVALID_CONFIGURATION",
109
+ message: "timeoutMs must be a positive number.",
110
+ stage: "validation",
111
+ nativeCode: nil,
112
+ nativeMessage: nil,
113
+ error: nil
114
+ )
68
115
  return
69
116
  }
70
117
 
71
118
  let password = call.getString("password")
119
+ if let password = password, !password.isEmpty, !isValidWpaPassphrase(password) {
120
+ finishConnectAttempt(generation)
121
+ rejectConnect(
122
+ call,
123
+ code: "INVALID_CONFIGURATION",
124
+ message: "Invalid WPA passphrase format.",
125
+ stage: "validation",
126
+ nativeCode: nil,
127
+ nativeMessage: nil,
128
+ error: nil
129
+ )
130
+ return
131
+ }
72
132
 
73
133
  let configuration: NEHotspotConfiguration
74
134
  if let password = password, !password.isEmpty {
@@ -78,13 +138,47 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
78
138
  }
79
139
 
80
140
  configuration.joinOnce = false
141
+ let deadline = Date().addingTimeInterval(timeoutMs / 1000.0)
81
142
 
82
- hotspotManager?.apply(configuration) { error in
83
- if let error = error {
84
- call.reject("Failed to connect: \(error.localizedDescription)", nil, error)
85
- } else {
86
- call.resolve()
143
+ guard let manager = hotspotManager else {
144
+ finishConnectAttempt(generation)
145
+ rejectConnect(
146
+ call,
147
+ code: "UNKNOWN",
148
+ message: "Hotspot configuration manager is unavailable.",
149
+ stage: "request",
150
+ nativeCode: nil,
151
+ nativeMessage: nil,
152
+ error: nil
153
+ )
154
+ return
155
+ }
156
+
157
+ manager.apply(configuration) { [weak self] error in
158
+ guard let self = self else { return }
159
+
160
+ if let error = error as NSError? {
161
+ if error.domain == NEHotspotConfigurationErrorDomain,
162
+ error.code == NEHotspotConfigurationError.alreadyAssociated.rawValue {
163
+ self.verifyConnectedSsid(ssid, generation: generation, deadline: deadline, call: call)
164
+ return
165
+ }
166
+
167
+ let mapped = self.mapHotspotConfigurationError(error)
168
+ self.finishConnectAttempt(generation)
169
+ self.rejectConnect(
170
+ call,
171
+ code: mapped.code,
172
+ message: mapped.message,
173
+ stage: mapped.stage,
174
+ nativeCode: error.code,
175
+ nativeMessage: error.localizedDescription,
176
+ error: error
177
+ )
178
+ return
87
179
  }
180
+
181
+ self.verifyConnectedSsid(ssid, generation: generation, deadline: deadline, call: call)
88
182
  }
89
183
  }
90
184
 
@@ -284,6 +378,124 @@ public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManager
284
378
  call.resolve(["version": self.pluginVersion])
285
379
  }
286
380
 
381
+
382
+ private func resolveTimeoutMs(_ call: CAPPluginCall) -> Double? {
383
+ if !call.hasOption("timeoutMs") {
384
+ return defaultConnectTimeoutMs
385
+ }
386
+ if let value = call.getDouble("timeoutMs") {
387
+ return value > 0 ? value : nil
388
+ }
389
+ if let value = call.getInt("timeoutMs") {
390
+ return value > 0 ? Double(value) : nil
391
+ }
392
+ return nil
393
+ }
394
+
395
+ private func finishConnectAttempt(_ generation: Int) {
396
+ connectLock.lock()
397
+ if connectGeneration == generation {
398
+ connectInProgress = false
399
+ }
400
+ connectLock.unlock()
401
+ }
402
+
403
+ private func isCurrentConnectAttempt(_ generation: Int) -> Bool {
404
+ connectLock.lock()
405
+ defer { connectLock.unlock() }
406
+ return connectGeneration == generation && connectInProgress
407
+ }
408
+
409
+ private func verifyConnectedSsid(_ expectedSsid: String, generation: Int, deadline: Date, call: CAPPluginCall) {
410
+ Task { [weak self] in
411
+ guard let self = self else { return }
412
+
413
+ while true {
414
+ guard self.isCurrentConnectAttempt(generation) else { return }
415
+
416
+ if Date() > deadline {
417
+ self.finishConnectAttempt(generation)
418
+ self.rejectConnect(
419
+ call,
420
+ code: "CONNECTION_TIMEOUT",
421
+ message: "Timed out waiting for Wi-Fi connection confirmation.",
422
+ stage: "verification",
423
+ nativeCode: nil,
424
+ nativeMessage: nil,
425
+ error: nil
426
+ )
427
+ return
428
+ }
429
+
430
+ if let current = await self.fetchCurrentNetwork()?.ssid, current == expectedSsid {
431
+ self.finishConnectAttempt(generation)
432
+ call.resolve()
433
+ return
434
+ }
435
+
436
+ try? await Task.sleep(nanoseconds: UInt64(self.ssidVerifyPollSeconds * 1_000_000_000))
437
+ }
438
+ }
439
+ }
440
+
441
+ private func isValidWpaPassphrase(_ password: String) -> Bool {
442
+ let length = password.count
443
+ if length >= 8 && length <= 63 {
444
+ return true
445
+ }
446
+ if length == 64 {
447
+ let hex = CharacterSet(charactersIn: "0123456789abcdefABCDEF")
448
+ return password.unicodeScalars.allSatisfy { hex.contains($0) }
449
+ }
450
+ return false
451
+ }
452
+
453
+ private func mapHotspotConfigurationError(_ error: NSError) -> (code: String, message: String, stage: String) {
454
+ guard error.domain == NEHotspotConfigurationErrorDomain,
455
+ let hotspotError = NEHotspotConfigurationError(rawValue: error.code) else {
456
+ return ("UNKNOWN", "An unexpected Wi-Fi connection error occurred.", "request")
457
+ }
458
+
459
+ switch hotspotError {
460
+ case .invalidSSID, .invalidSSIDPrefix, .invalidWPAPassphrase, .invalidWEPPassphrase,
461
+ .invalidEAPSettings, .invalidHS20Settings, .invalidHS20DomainName:
462
+ return ("INVALID_CONFIGURATION", "Invalid Wi-Fi connection configuration.", "validation")
463
+ case .userDenied:
464
+ return ("USER_DENIED", "The user denied the Wi-Fi connection request.", "request")
465
+ case .pending:
466
+ return ("CONNECTION_IN_PROGRESS", "Another Wi-Fi connection attempt is already in progress.", "request")
467
+ case .internal, .systemConfiguration, .joinOnceNotSupported, .applicationIsNotInForeground:
468
+ return ("CONNECTION_FAILED", "Failed to connect to network.", "request")
469
+ case .invalid, .unknown:
470
+ return ("UNKNOWN", "An unexpected Wi-Fi connection error occurred.", "request")
471
+ case .alreadyAssociated:
472
+ return ("CONNECTION_FAILED", "Failed to connect to network.", "verification")
473
+ @unknown default:
474
+ return ("CONNECTION_FAILED", "Failed to connect to network.", "request")
475
+ }
476
+ }
477
+
478
+ private func rejectConnect(
479
+ _ call: CAPPluginCall,
480
+ code: String,
481
+ message: String,
482
+ stage: String,
483
+ nativeCode: Int?,
484
+ nativeMessage: String?,
485
+ error: Error?
486
+ ) {
487
+ var data = JSObject()
488
+ data["platform"] = "ios"
489
+ data["connectionStage"] = stage
490
+ if let nativeCode = nativeCode {
491
+ data["nativeCode"] = nativeCode
492
+ }
493
+ if let nativeMessage = nativeMessage {
494
+ data["nativeMessage"] = nativeMessage
495
+ }
496
+ call.reject(message, code, error, data)
497
+ }
498
+
287
499
  // MARK: - Helper Methods
288
500
 
289
501
  /// Fetches the current Wi-Fi network asynchronously.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-wifi",
3
- "version": "8.4.1",
3
+ "version": "8.5.0-beta.pr20.12.1",
4
4
  "description": "Manage WiFi connectivity for your Capacitor app",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",