Skip to content

Support risk intelligence - #12

Merged
rokostik merged 16 commits into
mainfrom
rok/add-risk-intelligence
Mar 16, 2026
Merged

rokostik merged 16 commits into
mainfrom
rok/add-risk-intelligence

Conversation

@rokostik

@rokostik rokostik commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds support for risk intelligence and adds an example demo integration.

Because the SDK hasn't been released yet testing requires you to serve the SDK from a local server and change it's path in the demo HTML)

Comment thread example/captcha/go.mod Outdated
Comment on lines +9 to +10
// TODO comment out this line when new SDK version is released and dependency is updated
replace github.com/friendlycaptcha/friendly-captcha-go => ../..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be changed after merging this PR and bumping the github.com/friendlycaptcha/friendly-captcha-go version above. Otherwise the build would fail because of an unused dependency (github.com/guregu/null/v6)

@rokostik rokostik self-assigned this Mar 3, 2026
@rokostik
rokostik requested review from greenberga and gzuidhof March 3, 2026 13:22
Comment thread example/risk-intelligence/main.go Outdated
// This should never happen since /retrieve should always return
// risk intelligence data if the token is valid and request is successful.
// But it's good practice to handle it just in case.
data.Message = "Token was valid, but risk intelligence data was returned."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this message should be Token was valid, but risk intelligence data was not returned.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, my bad.

Comment thread example/risk-intelligence/demo.html Outdated

riEl?.addEventListener("frc:riskintelligence.complete", (ev) => {
hasTokenState = true;
setStatus(`complete\n token ready\n expiresAt: ${ev.detail.expiresAt.toISOString()}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we changed this from a Date to a number, this should now be ${new Date(ev.detail.expiresAt).toISOString()}

@greenberga greenberga left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

Comment thread wire.go

// RiskIntelligenceRetrieveResponseData is the data field in a successful retrieve response.
type RiskIntelligenceRetrieveResponseData struct {
// EventID is a unique identifier for this risk intelligence retrieve call.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment should be updated to read that it's a unique identifier for the event that generated the risk intelligence data (the one originating from the browser)

(I.e. this won't change if you call it multiple times with the same risk intelligence token)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is unique per a /retrieve call. IIRC it's the same as with /siteverify. The point of it is for us to be able to look into the data when requested so it doesn't really matter since we also save the token ID to the DB.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(There is a separate TokenID that is unique per token, IIRC)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thank you for the explanation, I somehow was convinced for siteverify it was tied to the activate call, but I was wrong about that :)

@rokostik
rokostik merged commit 2789624 into main Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants