0

I am trying to get the privatePasswordLeakVerification property back from a reCaptcha Enterprise assessment using the RecaptchaEnterpriseServiceClient. I have billing enabled. I am using the Node.js example found at link below although I am not using TypeScript:

https://cloud.google.com/recaptcha-enterprise/docs/check-passwords#recaptcha_enterprise_password_leak_verification-typescript

Here is an example of the code I am using to make the request:

const {RecaptchaEnterpriseServiceClient} = require("@google-cloud/recaptcha-enterprise");

const {PasswordCheckVerification} = require('recaptcha-password-check-helpers');

const client = new RecaptchaEnterpriseServiceClient({
  credentials: JSON_FILE
});

async function checkPasswordLeak(
  projectId,
  username,
  password,
  token
) {

  const verification = await PasswordCheckVerification.create(username, password);

  const lookupHashPrefix = Buffer.from(
    verification.getLookupHashPrefix()
  ).toString('base64');

  const encryptedUserCredentialsHash = Buffer.from(
    verification.getEncryptedUserCredentialsHash()
  ).toString('base64');

  const createAssessmentRequest = {
    parent: `projects/${projectId}`,
    assessment: {
      privatePasswordLeakVerification: {
        lookupHashPrefix,
        encryptedUserCredentialsHash,
      },
      event: {
        token,
        siteKey
      }
    },
  };

  const [response] = await client.createAssessment(createAssessmentRequest);

  return response;

}

Here is the response I get back:

{
  name: 'projects/111111111111/assessments/111111111111111',
  event: {
    token: '...',
    siteKey: '...',
    userAgent: '',
    userIpAddress: '',
    expectedAction: '',
    hashedAccountId: { type: 'Buffer', data: [] }
  },
  riskAnalysis: { reasons: [], score: 0.8999999761581421 },
  tokenProperties: {
    valid: true,
    invalidReason: 'INVALID_REASON_UNSPECIFIED',
    createTime: { seconds: '1685499273', nanos: 677000000 },
    hostname: 'localhost',
    action: 'LOGIN'
  },
  accountDefenderAssessment: null
}

As you can see I have no privatePasswordLeakVerification property in the reponse object.

Mr. J
  • 307
  • 2
  • 9

0 Answers0