Git Product home page Git Product logo

hcaptcha-ios-sdk's People

Contributors

akaduality avatar alldmeat avatar camobap avatar dependabot[bot] avatar e271828- avatar nehaisasha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hcaptcha-ios-sdk's Issues

Performance: switch HTML resource to string to allow static linking

Feature description

The SDK includes a html file as a resource. This prevents linking the library statically, which has the benefit of reducing the time for launching apps.

Goal of change: provide the html data as a string in source code. For our dev/debug sanity, we may want this to be done at build time by reading in the file.

Requirements

  • read in HTML as a string at build time.
  • Update Example app to demonstrate static linking, adding this to our test matrix alongside dynamic
  • Update docs to mention static vs. dynamic performance boost

Fix CI deprecation warnings

  • Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16
  • The set-output command is deprecated and will be disabled soon.

Accessibility link not opening external safari in iOS SDK

Problem

Go to Accessibility settings:
Screen Shot 2022-10-10 at 12 21 06 PM
Screen Shot 2022-10-10 at 12 21 20 PM

Try to click on the links:

  • Visit hcaptcha.com to learn more about the service and its accessibility options.
  • Retrieve accessibility token

Result: nothing happens

The expected result

Users should be redirected to hcaptcha.com website

"Terms" and "Privacy" links don't open external Safari

Bug description

Terms or Privacy links should lead to corresponding pages

To Reproduce

hcaptcha.validate and try to click Terms or Privacy links

Expected behavior

Terms or Privacy links should lead to corresponding pages

Additional context

It works on Android

Add a way to force the manager to call the configureWebView method

Feature description

Add a method to explicitly allow the user of the package to redraw the webview. This would allow a user to update the webviews bounds depending on the state of the hcapcha challenge.

Currently AFAIK, the webview can only be sized at init or when reset(), I'd like to change the webview bounds when the challenge is passed with success.

Requirements

The feature will be complete when these things are done:

  • We can explicitly reset the webview's bounds without reloading the webview, effectively bypassing the configureWebViewDispatchToken

Other comments (optional)

I'm currently bypassing this locally by adding a reload method to the Hcapcha class, which calls a forceRedrawWebView to the Hcapcha manager, which then call the configureWebview closure passed at initialisation time, but I'd like this to be in the source package.

Slow init because of DebugInfo

There seems to be a delay on init, and it blocks the thread, looks like it is this:
public let json: String = HCaptchaDebugInfo.buildDebugInfoJson()

If I disable the buildDebugInfoJson() then the init is instant.

I tried multiple versions, and all work the same. It is especially apparent on the simulator.

Error on integration with ionic project

Hi,
I tried to integrate the hCaptcha ios SDK with my ionic app. I can send the data from the javascript to the native code (siteKey) but I'm not sure how to show the captcha challenge

import Capacitor
import HCaptcha

@objc(HCaptchaPlugin)
public class HCaptchaPlugin: CAPPlugin {
  @objc func verifyCaptcha(_ call: CAPPluginCall) {
    let siteKey = call.getString("siteKey") ?? ""
    
    DispatchQueue.main.sync {  // <= run this code in main thread
        let hcaptcha = try? HCaptcha(
            apiKey: siteKey,
            baseURL: URL(string: "https://hcaptcha.com")! // not sure why we need this one, I don't see it on the android sdk ?
        )

        hcaptcha?.configureWebView { [weak self] webview in
                webview.frame = self?.bridge?.viewController?.view.bounds ?? CGRect.zero
            }
        
        // I'm not sure how to get view  input here, is `self.bridge?.webView` right?
        hcaptcha?.validate(on: self.bridge?.webView as! UIView) { [weak self] (result: HCaptchaResult) in
            call.resolve([
                "data": result,
                "status": "success"
            ])
        }
    }
  }
}

I made it work on Android but not on iOS 🤔
Log on Xcode:

To Native ->  hCaptcha verifyCaptcha 91927509
2021-07-23 09:47:03.292207+0700 App[848:661499] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2021-07-23 09:47:03.292294+0700 App[848:661499] WF: _WebFilterIsActive returning: NO
2021-07-23 09:47:21.399858+0700 App[848:661499] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2021-07-23 09:47:21.401830+0700 App[848:661499] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service

Thanks.

Funds

Before opening an issue, check the following:

  1. You are using the SITE key.
  2. The correct domain, with protocol, is set up.
  3. You are using an hCaptcha key. It does NOT start with 0x. That's a secret key.
  4. If the widget doesn't appear, that is expected since the library will try to resolve the challenge invisibly.

Bug description

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '...'
  3. ...

Debug Logs

The HCaptcha constructor accepts a diagnosticLog flag (bool) to enable detailed SDK logs. If you would like to report an issue with the SDK, please enable this flag and attach diagnosticLog output when you open the issue.

Expected behavior

A clear and concise description of what you expected to happen.

Logs

Please add as many logs as you feel necessary. Be mindful of your application and remove any sensitive data.

Additional context

Add any other context about the problem here.

Release 1.8.0

Requirements

The feature will be complete when these things are done:

  • CHANGELOG.md updated
  • version bumped
  • Any README changes needed are added

2.4.0 release failed

https://github.com/hCaptcha/HCaptcha-ios-sdk/actions/runs/4000836391

...
/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/CocoaPods-Lint-20230124-2729-lan9ye-HCaptcha/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.2.99. (in target 'Pods-App' from project 'Pods')
[22:35:20]: ▸ /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/CocoaPods-Lint-20230124-2729-lan9ye-HCaptcha/App.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.2.99. (in target 'App' from project 'App')
[22:35:20]: ▸ error: Cannot code sign because the target does not have an Info.plist file and one is not being generated automatically. Apply an Info.plist file to the target using the INFOPLIST_FILE build setting or generate one automatically by setting the GENERATE_INFOPLIST_FILE build setting to YES (recommended). (in target 'App' from project 'App')
[22:35:20]: ▸ /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/CocoaPods-Lint-[202](https://github.com/hCaptcha/HCaptcha-ios-sdk/actions/runs/4000836391/jobs/6866779682#step:4:203)30124-2729-lan9ye-HCaptcha/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.2.99. (in target 'HCaptcha' from project 'Pods')
...

Question on configureWebView and view.bounds

Question received:

configureWebView() is required to be called, but does it require the webview to be set to the view.bounds? When setting it to view.bounds, it seems that even after the invisible challenge is completed, the webview doesn't go away resulting in a blank screen on top of the underlying view. When setting it to CGRect.zero, it doesn't block the view at all, so can we do that?

Action items

  • check if webview.bounds = view.bounds required
  • check issue with webview (doesn't go away)
  • check proposed workaround

Query: adding hCaptcha WkWebview to a container with a blur background

Report: when adding the hCaptcha WkWebview to a container with a blur background the Webview is not loading sometimes.

Snippet:

hcaptcha?.configureWebView { [weak self] webview in
            webview.frame = self?.captchaContainerView.bounds ?? CGRect.zero
        }
        
        hcaptcha?.validate(on: captchaContainerView,
                           resetOnError: true,
                           completion: { [weak self] result in
            guard let self = self else {
                completionHandler(false, nil, ZError.default)
                return
            }
            
            self.captchaBackgroundView.zHide()
            self.captchaBackgroundView.removeFromSuperview()
            
            self.hcaptcha?.stop()
            if let data = try? result.dematerialize() {
                ZLog.i(data)
                completionHandler(true, data, nil)
            }
            else {
                completionHandler(false, nil, ZError.default)
            }
        })

81

Before opening an issue, check the following:

  1. You are using the SITE key.
  2. The correct domain, with protocol, is set up.
  3. You are using an hCaptcha key. It does NOT start with 0x. That's a secret key.
  4. If the widget doesn't appear, that is expected since the library will try to resolve the challenge invisibly.

Bug description

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '...'
  3. ...

Debug Logs

The HCaptcha constructor accepts a diagnosticLog flag (bool) to enable detailed SDK logs. If you would like to report an issue with the SDK, please enable this flag and attach diagnosticLog output when you open the issue.

Expected behavior

A clear and concise description of what you expected to happen.

Logs

Please add as many logs as you feel necessary. Be mindful of your application and remove any sensitive data.

Additional context

Add any other context about the problem here.

Support passing standard `theme` and `customTheme` object to init

Feature description

Add support for JS SDK's theme features.

Requirements

The feature will be complete when these things are done:

  • Can pass theme option into init.

Example string values: light dark etc: https://docs.hcaptcha.com/configuration#themes

  • Can pass customTheme object into init.

Usage looks like:

  1. passing a value in init causes it to add custom=true to api.js params.

  2. render function is updated to execute following this pattern:

    var onLoad = function() {
      hcaptcha.render("h-captcha", {
        "sitekey": "<sitekey>",
        "theme"  : {
          primary: {
            main: "#00FF00"
          },
          text: {
            heading: "#454545",
            body   : "#8C8C8C"
          }
        }
      });
    };
  • README updated to describe usage.

Other comments

  1. Custom themes will only work on an enabled enterprise sitekey
  2. We probably want to specify that customTheme is provided to init as JSON for everyone's sanity.

iOS 14.x M1 simulators have a known issue with some standard features

Bug description

Captcha is not displaying puzzle using iOS 14.5 Simulator

To Reproduce

Steps to reproduce the behavior:

  1. Initialize hCaptcha somewhere
  2. Try to call hCaptcha.validate using iOS 14.5 Simulator
  3. That step depends on config.
    If using invisible then nothing happens at all, but if compact is being used, then checkmark displays, but after pressing 'I am a human' nothing happens except one flicker.

Sample code:

captchaWebView?.removeFromSuperview()
        hCaptcha.configureWebView { [weak self] webview in
            self?.captchaWebView = webview
            webview.frame = view.bounds
        }
        
        hCaptcha.validate(on: view) { [weak self] result in
            guard let self = self else {
                return
            }
            print(try! result.dematerialize())
            self.captchaWebView?.removeFromSuperview()
        }

Expected behavior

hCaptcha displays puzzle

Logs

[JS LOG]: challenge executing
[JS LOG]: showing challenge
2022-12-08 23:55:41.012306+1000 APP_NAME[92271:1276150] [ProcessSuspension] 0x12b1b1c80 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID is invalid
2022-12-08 23:55:41.012478+1000 APP_NAME[92271:1276150] [Process] 0x152859018 - [pageProxyID=5, webPageID=6, PID=92278] WebPageProxy::processDidTerminate: (pid 92278), reason 3
2022-12-08 23:55:41.026291+1000 APP_NAME[92271:1276150] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2022-12-08 23:55:41.026374+1000 APP_NAME[92271:1276150] [ProcessSuspension] 0x12b1b1cc0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 92278, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2022-12-08 23:55:41.029488+1000 APP_NAME[92271:1276150] [Loading] 0x152859018 - [pageProxyID=5, webPageID=6, PID=92278] WebPageProxy::dispatchProcessDidTerminate: reason = 3

Additional context

Seems like thats an iOS bug related to WKWebView. I've tried enabling background capabilities but it didnt help. We have our own implementation of Google's ReCaptcha but I dont see any big difference in codes related to webview handling, so I am not kind of sure thats WKWebView problem

image

sdk errors

why iOS sdk errors different from android sdk errors? I need to handle for example this one

    /**
     * Internet connection is missing.
     *
     * Make sure AndroidManifest requires internet permission: {@code {@literal <}uses-permission android:name="android.permission.INTERNET" /{@literal >}}
     */
    NETWORK_ERROR(7, "No internet connection"),

    /**
     * hCaptcha session timed out either the token or challenge expired
     */
    SESSION_TIMEOUT(15, "Session Timeout"),

    /**
     * Rate limited due to too many tries.
     */
    RATE_LIMITED(31, "Rate Limited"),

but instead it stays at the JS log level

Release 1.7.0

Requirements

The release will be complete when these things are done:

  • core Enterprise init options are merged.
  • customTheme support is merged.
  • release is automated via Github Action workflow.

Enforce ES5 to ensure compatibility with old iOS versions

iOS versions below 10.0 require ES5. This is way less than 1% of devices. Do we still care? Unclear, but it is a small amount of effort to stay compatible.

In the future, we may instead babelize the JS to ES5 to ensure compatibility with old iOS versions once we start using ES6 features.

Tests failed in new Xcode 15.2

Also Xcode reports complation issues while it still allows to run the Example targets

/ios-sdk/Example/HCaptcha/ViewController.swift:9:8 Compiling for iOS 9.0, but module 'HCaptcha' has a minimum deployment target of iOS 12.0: /Users/camobap/Library/Developer/Xcode/DerivedData/HCaptcha-dwcvhnkghmwotpfcynmdvgucadgn/Index.noindex/Build/Products/Debug-iphonesimulator/HCaptcha.swiftmodule/x86_64-apple-ios-simulator.swiftmodule

/ios-sdk/Example/HCaptcha/ViewController.swift:80:21 Dynamic key path member lookup cannot refer to instance method 'didFinishLoading'

/ios-sdk/Example/HCaptcha/ViewController.swift:81:14 Value of type 'Binder<((() -> Void)?) -> ()>' has no member 'debug'

/ios-sdk/Example/HCaptcha/ViewController.swift:85:21 Cannot call value of non-function type 'Binder<_>'

/ios-sdk/Example/HCaptcha/ViewController.swift:85:21 Value of type 'Reactive<HCaptcha>' has no dynamic member 'events' using key path from root type 'HCaptcha'

/ios-sdk/Example/HCaptcha/ViewController.swift:87:39 Cannot infer type of closure parameter 'event' without a type annotation

/ios-sdk/Example/HCaptcha/ViewController.swift:87:46 Cannot infer type of closure parameter 'data' without a type annotation

/ios-sdk/Example/HCaptcha/ViewController.swift:104:36 Cannot call value of non-function type 'Binder<(UIView, Bool, @escaping (HCaptchaResult) -> Void) -> ()>'

/ios-sdk/Example/HCaptcha/ViewController.swift:104:36 Dynamic key path member lookup cannot refer to instance method 'validate(on:resetOnError:completion:)'

/ios-sdk/Example/HCaptcha/ViewController.swift:106:25 Cannot infer contextual base in reference to member 'just'

/ios-sdk/Example/HCaptcha/ViewController.swift:130:32 Cannot infer type of closure parameter '_' without a type annotation

SwiftUI Code does not work within NavigationView

The Swift UI Example from the documentation works just fine, as long as you have not included the code into a NavigationView. If the code is used as the second view in a navigation view, as soon as you hit 'validate', the challenge is issued, but not shown on the screen. After some time, the challenge resets and finally is shown, but it takes about a minute or longer, which is too long for my users to wait.

Maybe I am doing something wrong here. Hints would be much appreciated. On the other hand, maybe the SwiftUI example is too simplistic and should be updated with further details.

I am too unexperienced to see what the problem is, but I've created a reproducer and I got the log output, which reads:

=== AttributeGraph: cycle detected through attribute 7744 ===
2022-07-22 08:50:26.703200+0200 HCaptchaTest[77715:5241039] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60000062ed50 'BIB_Leading_Leading' H:|-(0)-[_UIModernBarButton:0x150679bf0]   (active, names: '|':_UIButtonBarButton:0x15211f930 )>",
    "<NSLayoutConstraint:0x60000062fac0 'UINav_static_button_horiz_position' _UIModernBarButton:0x150679bf0.leading == UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x60000062fb10 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x15211f930]-(6)-[UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide']   (active)>",
    "<NSLayoutConstraint:0x600000658e60 'UINavItemContentGuide-trailing' UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x15211a4b0.trailing   (active)>",
    "<NSLayoutConstraint:0x6000006251d0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x15211a4b0.width == 0   (active)>",
    "<NSLayoutConstraint:0x600000659180 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x15211a4b0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000062ed50 'BIB_Leading_Leading' H:|-(0)-[_UIModernBarButton:0x150679bf0]   (active, names: '|':_UIButtonBarButton:0x15211f930 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2022-07-22 08:50:26.703626+0200 HCaptchaTest[77715:5241039] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60000062eda0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x150679bf0]-(6)-[_UIModernBarButton:0x15211fd10'Main Page']   (active)>",
    "<NSLayoutConstraint:0x60000062edf0 'CB_Trailing_Trailing' _UIModernBarButton:0x15211fd10'Main Page'.trailing <= _UIButtonBarButton:0x15211f930.trailing   (active)>",
    "<NSLayoutConstraint:0x60000062fac0 'UINav_static_button_horiz_position' _UIModernBarButton:0x150679bf0.leading == UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x60000062fb10 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x15211f930]-(6)-[UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide']   (active)>",
    "<NSLayoutConstraint:0x600000658e60 'UINavItemContentGuide-trailing' UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x15211a4b0.trailing   (active)>",
    "<NSLayoutConstraint:0x6000006251d0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x15211a4b0.width == 0   (active)>",
    "<NSLayoutConstraint:0x600000659180 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x15211a4b0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000062eda0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x150679bf0]-(6)-[_UIModernBarButton:0x15211fd10'Main Page']   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2022-07-22 08:50:26.704075+0200 HCaptchaTest[77715:5241039] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60000062e2b0 UIView:0x15067c2d0.trailing == _UIBackButtonMaskView:0x15067bb70.trailing   (active)>",
    "<NSLayoutConstraint:0x60000062f390 'Mask_Trailing_Trailing' _UIBackButtonMaskView:0x15067bb70.trailing == _UIButtonBarButton:0x15211f930.trailing   (active)>",
    "<NSLayoutConstraint:0x60000062f4d0 'MaskEV_Leading_BIB_Trailing' H:[_UIModernBarButton:0x150679bf0]-(0)-[UIView:0x15067c2d0]   (active)>",
    "<NSLayoutConstraint:0x60000062fac0 'UINav_static_button_horiz_position' _UIModernBarButton:0x150679bf0.leading == UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x60000062fb10 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x15211f930]-(6)-[UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide']   (active)>",
    "<NSLayoutConstraint:0x600000658e60 'UINavItemContentGuide-trailing' UILayoutGuide:0x600001c15a40'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x15211a4b0.trailing   (active)>",
    "<NSLayoutConstraint:0x6000006251d0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x15211a4b0.width == 0   (active)>",
    "<NSLayoutConstraint:0x600000659180 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600001c15b20'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x15211a4b0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000062e2b0 UIView:0x15067c2d0.trailing == _UIBackButtonMaskView:0x15067bb70.trailing   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
[JS LOG]: recaptchacompat disabled
[JS LOG]: challenge onload starting
2022-07-22 08:50:26.921469+0200 HCaptchaTest[77715:5241039] [ViewportSizing] maximumViewportInset cannot be larger than frame
2022-07-22 08:50:26.921518+0200 HCaptchaTest[77715:5241039] [ViewportSizing] minimumViewportInset cannot be larger than frame
2022-07-22 08:50:26.921705+0200 HCaptchaTest[77715:5241039] [ViewportSizing] maximumViewportInset cannot be larger than frame
2022-07-22 08:50:26.921735+0200 HCaptchaTest[77715:5241039] [ViewportSizing] minimumViewportInset cannot be larger than frame
2022-07-22 08:50:30.037883+0200 HCaptchaTest[77715:5241039] [ViewportSizing] maximumViewportInset cannot be larger than frame
2022-07-22 08:50:30.038063+0200 HCaptchaTest[77715:5241039] [ViewportSizing] minimumViewportInset cannot be larger than frame
[JS LOG]: challenge executing
[JS LOG]: showing challenge
[JS LOG]: challenge opened
2022-07-22 08:50:31.845902+0200 HCaptchaTest[77715:5241039] [HardwareKeyboard] -[UIApplication getKeyboardDevicePropertiesForSenderID:shouldUpdate:usingSyntheticEvent:], failed to fetch device property for senderID (778835616971358211) use primary keyboard info instead.
2022-07-22 08:50:31.847408+0200 HCaptchaTest[77715:5241039] [HardwareKeyboard] -[UIApplication getKeyboardDevicePropertiesForSenderID:shouldUpdate:usingSyntheticEvent:], failed to fetch device property for senderID (778835616971358211) use primary keyboard info instead.
[JS LOG]: expired challenge
[JS LOG]: challenge resetting
[JS LOG]: challenge executing
[JS LOG]: showing challenge
[JS LOG]: challenge opened

HCaptcha Is Not Shown First Time, It Succeeds Seamlessly 🐛

Bug description

I'm using HCaptcha to save my app from being attacked with some requests so I need it to challenge our users every time, but the behaviour is when I do the captcha test for the first time, it's not shown, if I back on the same run and I clicked the button that launches the captcha again I will see it work, while the first time captcha returns valid token without running the manual quiz .

To Reproduce

Steps to reproduce the behavior:

  1. run the app with valid certificate on real devices, preferably from TestFlight.
  2. open your app and run the captcha make it pass for one time at least.
  3. close the app.
  4. run again and try to run the captcha quiz it will be seamless and you will get token but not quizes.
  5. back and click on your button that launches the captcha it will be shown normally.

Expected behavior

I need the test to be available every time I launch the captcha.

Additional context

  • I tried the reset function but it does nothing.
  • My app Configuration is always challenge.

Make error messages clearer when network is offline or interrupted

Right now we produce error messages like:

  • Can't find variable: reset
  • Can't find variable: execute

If resources cannot be loaded, e.g. if user goes out of service in the midst of a session.

  1. JS SDK calls should be wrapped in JS, return comprehensible error message ("could not load resources from network")
  2. We should look at robustifying this:
  • watchdog timer at N seconds (15?) if webview comes up but JS fails to load. (can be done in JS: setTimeout for 15s, check if window.hcaptcha exists)

frameworkPath: nil while unwrapping an Optional value

Screen Shot 2022-03-02 at 5 49 17 PM

thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
  frame #0: 0x000000010c91aa80 libswiftCore.dylib`_swift_runtime_on_report
  frame #1: 0x000000010c9950e3 libswiftCore.dylib`_swift_stdlib_reportFatalErrorInFile + 211
  frame #2: 0x000000010c624f30 libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 480
  frame #3: 0x000000010c624a87 libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 87
  frame #4: 0x000000010c624763 libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 99
  frame #5: 0x000000010c6243e1 libswiftCore.dylib`Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 513
  frame #6: 0x00000001070a678a MY-APP SEA`HCaptchaDebugInfo.buildDebugInfo(self=0x0000600000333b00) at HCaptchaDebugInfo.swift:44:66
  frame #7: 0x00000001070a6129 MY-APP SEA`HCaptchaDebugInfo.buildDebugInfoJson(self=0x0000600000333b00) at HCaptchaDebugInfo.swift:30:50
  frame #8: 0x00000001070a600a MY-APP SEA`HCaptchaDebugInfo.init(self=0x0000600000333b00) at HCaptchaDebugInfo.swift:24:26
  frame #9: 0x00000001070a5fc1 MY-APP SEA`HCaptchaDebugInfo.__allocating_init() at HCaptchaDebugInfo.swift:0
  frame #10: 0x00000001070ae604 MY-APP SEA`HCaptchaWebViewManager.init(html="<html>\n <head>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>\n  \n  <style>\n    * {\n      padding: 0;\n      margin: 0;\n    }\n    body {\n      display: table;\n      width: 100%;\n      height: 100%;\n      text-align: center;\n    }\n    #hcaptcha-container {\n      margin-top: 5px;\n      display: table-cell;\n      vertical-align: middle;\n    }\n    /* overwrite hCaptcha iframe overlay which adds a #FFF background with opacity 0.05 */\n    div > div:nth-child(2) {\n      opacity: 0 !important;\n    }\n  </style>\n  <script type=\"text/javascript\">\n   JSON.parse('${debugInfo}' || \"[]\").forEach(function (value, i) { window[value] = true; });\n  </script>\n  <script type=\"text/javascript\">\n   var script = document.createElement('script');\n   script.src = \"${endpoint}\";\n\n   script.onerror = function () {\n     // network issue\n     post({ error: 7 });\n  "..., apiKey="MY-SITEKEY", baseURL="https://localhost", endpoint="https://js.hcaptcha.com/1/api.js?onload=onloadCallback&render=explicit&recaptchacompat=off&host=MY-SITEKEY.ios-sdk.hcaptcha.com&sentry=false", size=invisible, rqdata=nil, theme="\"light\"", self=0x0000600003548420) at HCaptchaWebViewManager.swift:69:33

Integrating iOS SDK

Hey all,

I am trying to integrate HCaptcha for the first time into my project, I am running into an issue where I try to configure the web view and its valued as nil. Installed via CocoaPods. v.2.0.0

I have added my HCAPTCHA Key and HCaptchaDomain - "https://localhost.com" to my info.pList.

If anyone can help me troubleshoot, that would be great.

Thanks!
Screen Shot 2022-02-21 at 9 37 54 AM

Strange Behaviour when embedded in NavigationStack

Bug description

I try to add an HCaptchaView following the example to an iOS App build using SwiftUI. I've got a LoginScreen that is a NavigationStack and leads to a RegistrationScreen upon user request. The RegistrationScreen is embedded inside the NavigationStack from the LoginScreen, so the user can easily navigate back. The problem is, that the challenge takes forever to appear as long as I have that NavigationStack around everything. As soon as I remove the NavigationStack everything works fine.

To Reproduce

Steps to reproduce the behavior:

  1. Add a NavigationStack around the HCaptcha view (for example as part of the example application)
  2. Run the app and try to get a token
  3. It will take several minutes until the challenge appears (if at all).

Expected behavior

It should behave inside a NavigationStack the same way as outside of it

Context

I am using iOS 16.2 and version 2.5.0 of this library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.