POST /v1/assessments with your API key and acts on the account’s decision.
All three files work in the same way:
- They fail open. A missing key, an error, a slow answer or an unexpected reply lets the user through. The file writes one line to the log with the reason.
- They refuse only on
block. The decision isaccount.risk.decision.allow,step_up,reviewand a 202pendinganswer let the user through. Use late decisions to act on them later. - They send no secret to another host. The key goes only to an
httpsURL, and the files follow no redirect. - They drop a refused optional value. If the API refuses the IP, phone or name of the user, the file sends the request once more without that value.
auth_context with transport provider_hook, so NoResponse knows which provider made the call. The file is the only code that you add. It needs no package beyond the SDK of your auth provider.
Every file needs a NoResponse API key with the
assess scope. Use your test key (nrk_test_) first. Then the magic emails give a known decision, and each file refuses block@test.noresponse.org.Better Auth
The plugin assesses each new user indatabaseHooks.user.create.before. Better Auth calls this hook for email and password, social and magic link account creation. A refused user gets 403 with your message, and Better Auth stores no user. The plugin throws APIError, because a hook that returns false breaks social account creation.
Better Auth has no user id at this point. NoResponse thus gives the assessment an account id of its own, pre: and then the assessment id.
Copy the plugin
Save
noresponse.ts next to your Better Auth configuration.noresponse.ts
noresponse.ts
noresponse.ts
x-forwarded-for, or advanced.ipAddress.ipAddressHeaders when you set it. A header with more than one address gives no IP. With advanced.ipAddress.disableIpTracking, the plugin sends no IP.
Firebase
The blocking function runs before Firebase Authentication saves a new user. Blocking functions need Firebase Authentication with Identity Platform. Firebase allows a blocking function 7 seconds and refuses the account creation after that. The function thus stops the call to NoResponse after 5 seconds. The function sends the Firebase user id as theaccount_id. On held, it creates the user disabled. Your late-result handler enables the user when the final decision is allow.
Copy the function
Save
noresponse.ts in your functions folder and export the function from your entry file.index.ts
noresponse.ts
noresponse.ts
noresponse.ts
Amazon Cognito
The trigger runs before Cognito creates a new user. Cognito allows a trigger 5 seconds and can try it again. The trigger thus stops the call to NoResponse after 4 seconds, and each new try gets the same assessment. The trigger does not assess a user that an administrator creates withAdminCreateUser.
Cognito cannot create a user disabled from this trigger. On held, the trigger thus lets the user through. Your late-result handler disables the user with AdminDisableUser when the final decision is block.
The Cognito event carries no client IP. To send one, put it in ClientMetadata as noresponse_ip on the SignUp call from your backend.
Deploy the function
Put
pre-sign-up.mjs and template.yaml in one folder. Then deploy them with the AWS SAM CLI and give the ARN of your user pool and your key.Deploy
pre-sign-up.mjs
pre-sign-up.mjs
pre-sign-up.mjs
template.yaml
template.yaml
template.yaml
Tests
Each file has tests in its own folder of the NoResponse repository. They run the file with the real SDK of its auth provider against a scripted NoResponse endpoint. The tests cover each decision, each failure and the retry without a refused value.Admission and late decisions
Act on a decision that changes after the account exists.
Test your integration
The magic emails that give each decision with a test key.