@protontech/autofill 0.0.35059265 → 0.0.35481761

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.
Files changed (44) hide show
  1. package/features/feature.d.ts +13 -2
  2. package/features/feature.js +37 -15
  3. package/features/feature.spec.js +56 -7
  4. package/features/v1/abstract.field.d.ts +8377 -406
  5. package/features/v1/abstract.field.js +24 -24
  6. package/features/v1/abstract.form.d.ts +3428 -14
  7. package/features/v1/abstract.form.js +197 -197
  8. package/features/v1/field.email.d.ts +3421 -0
  9. package/features/v1/field.email.js +7 -7
  10. package/features/v1/field.otp.d.ts +71178 -0
  11. package/features/v1/field.otp.js +42 -42
  12. package/features/v1/field.password.d.ts +99166 -0
  13. package/features/v1/field.password.js +42 -42
  14. package/features/v1/field.username-hidden.d.ts +908 -0
  15. package/features/v1/field.username-hidden.js +7 -7
  16. package/features/v1/field.username.d.ts +42382 -0
  17. package/features/v1/field.username.js +11 -11
  18. package/features/v1/fields.sorted.gen.d.ts +1441 -0
  19. package/features/v1/fields.sorted.gen.js +344 -0
  20. package/features/v1/forms.sorted.gen.d.ts +734 -0
  21. package/features/v1/forms.sorted.gen.js +334 -0
  22. package/features/v1/index.d.ts +5305 -12
  23. package/features/v1/index.js +7 -11
  24. package/features/v1/index.spec.js +34 -20
  25. package/models/perceptron/params/login-model.json +91 -91
  26. package/models/perceptron/params/new-password-model.json +21 -21
  27. package/models/perceptron/params/otp-model.json +29 -29
  28. package/models/perceptron/params/password-change-model.json +72 -72
  29. package/models/perceptron/params/password-model.json +23 -23
  30. package/models/perceptron/params/recovery-model.json +81 -81
  31. package/models/perceptron/params/register-model.json +99 -99
  32. package/models/perceptron/params/username-hidden-model.json +10 -10
  33. package/models/perceptron/params/username-model.json +7 -7
  34. package/models/random_forest/params/otp-model.json +306 -366
  35. package/package.json +3 -3
  36. package/rules/v1/index.js +2 -2
  37. package/scripts/gen-sorted-features.js +125 -29
  38. package/types/index.d.ts +2 -1
  39. package/utils/fathom.d.ts +1 -2
  40. package/utils/fathom.js +2 -2
  41. package/features/registry.d.ts +0 -3
  42. package/features/registry.js +0 -9
  43. package/features/sorted.gen.d.ts +0 -14
  44. package/features/sorted.gen.js +0 -22
@@ -4,7 +4,7 @@ import { field, fieldAttrs, fieldAutocomplete, fieldCC, fieldForm, fieldFormFeat
4
4
  import { any } from "@protontech/autofill/utils/combinators";
5
5
  import { getNodeRect } from "@protontech/autofill/utils/dom";
6
6
  import { matchAuthenticator, matchOtpAttr, matchOtpFieldOutlier, matchTwoFa } from "@protontech/autofill/utils/re";
7
- const matchSibling = (sibling, match) => {
7
+ export const matchSibling = (sibling, match) => {
8
8
  if (!sibling)
9
9
  return false;
10
10
  if ((sibling === null || sibling === void 0 ? void 0 : sibling.getAttribute("type")) !== match.type)
@@ -28,51 +28,51 @@ const matchSibling = (sibling, match) => {
28
28
  return false;
29
29
  return true;
30
30
  };
31
- const searchForm = feature("searchForm", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.searchForm); });
32
- const formComplexity = feature("formComplexity", { fieldFormFeats }, (p) => { var _a, _b; return (_b = (_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formComplexityScaled) !== null && _b !== void 0 ? _b : 0; });
33
- const formMFA = feature("formMFA", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__formMFA); });
34
- const formAuthenticator = feature("formAuthenticator", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__formTextAuthenticator); });
35
- const mfaCandidates = feature("mfaCandidates", { fieldFormFeats }, (p) => { var _a, _b; return (_b = (_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__formInputMFACandidates) !== null && _b !== void 0 ? _b : 0; });
36
- const outlierForm = feature("outlierForm", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__formOTPOutlier); });
37
- const outlierLink = feature("outlierLink", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__linkOTPOutlier); });
38
- const outlierHeadings = feature("outlierHeadings", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.__headingsOTPOutlier); });
39
- const numericMode = feature("numericMode", { field }, (p) => p.field.inputMode === "numeric");
40
- const patternOTP = feature("patternOTP", { fieldPattern: pattern, numericMode }, (p) => !numericMode && OTP_PATTERNS.some((pattern) => { var _a; return ((_a = p.pattern) === null || _a === void 0 ? void 0 : _a.trim()) === pattern; }));
41
- const nameMatch = feature("nameMatch", { field }, (p) => ["code", "token", "otp", "otc", "totp"].some((match) => p.field.name === match));
42
- const idMatch = feature("idMatch", { field }, (p) => ["code", "token", "otp", "otc", "totp"].some((match) => p.field.id === match));
43
- const autocompleteOff = feature("autocompleteOff", { fieldAutocomplete }, (p) => p.fieldAutocomplete !== undefined && (p.fieldAutocomplete === "off" || p.fieldAutocomplete === "false"));
44
- const autocompleteOTC = feature("autocompleteOTC", { fieldAutocomplete }, (p) => { var _a, _b; return (_b = (_a = p.fieldAutocomplete) === null || _a === void 0 ? void 0 : _a.includes("one-time-code")) !== null && _b !== void 0 ? _b : false; });
45
- const maxLen = feature("maxLen", { fieldMaxLength: maxLength }, (p) => (p.maxLength ? parseInt(p.maxLength, 10) : null));
46
- const singleInput = feature("singleInput", { mfaCandidates }, (p) => p.mfaCandidates === 1);
47
- const rect = feature("rect", { field }, (p) => getNodeRect(p.field));
48
- const similarBefore = feature("similarBefore", { type, fieldPrev, rect }, (p) => matchSibling(p.fieldPrev, p));
49
- const similarAfter = feature("similarAfter", { type, fieldNext, rect }, (p) => matchSibling(p.fieldNext, p));
50
- const siblingOfInterest = feature("siblingOfInterest", { similarBefore, similarAfter }, (p) => p.similarBefore || p.similarAfter);
51
- const attrOTP = feature("attrOTP", { fieldAttrs }, (p) => any(matchOtpAttr)(p.fieldAttrs));
52
- const attrMFA = feature("attrMFA", { fieldAttrs }, (p) => any(matchTwoFa)(p.fieldAttrs));
53
- const attrOutlier = feature("attrOutlier", { fieldAttrs }, (p) => any(matchOtpFieldOutlier)(p.fieldAttrs));
54
- const textOTP = feature("textOTP", { fieldText }, (p) => matchOtpAttr(p.fieldText));
55
- const textMFA = feature("textMFA", { fieldText }, (p) => matchTwoFa(p.fieldText));
56
- const textAuthenticator = feature("textAuthenticator", { fieldText }, (p) => matchAuthenticator(p.fieldText));
57
- const labelOTP = feature("labelOTP", { fieldLabel }, (p) => matchOtpAttr(p.fieldLabel));
58
- const labelMFA = feature("labelMFA", { fieldLabel }, (p) => matchTwoFa(p.fieldLabel));
59
- const labelAuthenticator = feature("labelAuthenticator", { fieldLabel }, (p) => matchAuthenticator(p.fieldLabel));
60
- const labelOutlier = feature("labelOutlier", { fieldLabel }, (p) => matchOtpFieldOutlier(p.fieldLabel));
61
- const mfa = feature("mfa", { formMFA, labelMFA, textMFA, attrMFA }, (p) => p.formMFA || p.labelMFA || p.textMFA || p.attrMFA);
62
- const otp = feature("otp", { attrOTP, textOTP, labelOTP }, (p) => p.attrOTP || p.textOTP || p.labelOTP);
63
- const outlierCandidate = feature("outlierCandidate", { mfa, otp }, (p) => p.mfa || p.otp);
64
- const outlierMaxLength = feature("outlierMaxLength", { maxLen }, (p) => Boolean(p.maxLen && (p.maxLen > 20 || (p.maxLen > 1 && p.maxLen < 5))));
65
- const outlierInputCount = feature("outlierInputCount", { mfaCandidates }, (p) => !(p.mfaCandidates === 1 || p.mfaCandidates === 6 || p.mfaCandidates === 5));
66
- const outlierEmailMatchRaw = feature("outlierEmailMatch", { outlierCandidate, fieldForm }, (p) => {
31
+ export const searchForm = feature("searchForm", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.searchForm); });
32
+ export const formComplexity = feature("formComplexity", { fieldFormFeats }, (p) => { var _a, _b; return (_b = (_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formComplexityScaled) !== null && _b !== void 0 ? _b : 0; });
33
+ export const formMFA = feature("formMFA", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formMFA); });
34
+ export const formAuthenticator = feature("formAuthenticator", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formTextAuthenticator); });
35
+ export const mfaCandidates = feature("mfaCandidates", { fieldFormFeats }, (p) => { var _a, _b; return (_b = (_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formInputMFACandidates) !== null && _b !== void 0 ? _b : 0; });
36
+ export const outlierForm = feature("outlierForm", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.formOTPOutlier); });
37
+ export const outlierLink = feature("outlierLink", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.linkOTPOutlier); });
38
+ export const outlierHeadings = feature("outlierHeadings", { fieldFormFeats }, (p) => { var _a; return Boolean((_a = p.fieldFormFeats) === null || _a === void 0 ? void 0 : _a.headingsOTPOutlier); });
39
+ export const numericMode = feature("numericMode", { field }, (p) => p.field.inputMode === "numeric");
40
+ export const patternOTP = feature("patternOTP", { fieldPattern: pattern, numericMode }, (p) => !p.numericMode && OTP_PATTERNS.some((pattern) => { var _a; return ((_a = p.pattern) === null || _a === void 0 ? void 0 : _a.trim()) === pattern; }));
41
+ export const nameMatch = feature("nameMatch", { field }, (p) => ["code", "token", "otp", "otc", "totp"].some((match) => p.field.name === match));
42
+ export const idMatch = feature("idMatch", { field }, (p) => ["code", "token", "otp", "otc", "totp"].some((match) => p.field.id === match));
43
+ export const autocompleteOff = feature("autocompleteOff", { fieldAutocomplete }, (p) => p.fieldAutocomplete !== undefined && (p.fieldAutocomplete === "off" || p.fieldAutocomplete === "false"));
44
+ export const autocompleteOTC = feature("autocompleteOTC", { fieldAutocomplete }, (p) => { var _a, _b; return (_b = (_a = p.fieldAutocomplete) === null || _a === void 0 ? void 0 : _a.includes("one-time-code")) !== null && _b !== void 0 ? _b : false; });
45
+ export const maxLen = feature("maxLen", { fieldMaxLength: maxLength }, (p) => (p.maxLength ? parseInt(p.maxLength, 10) : null));
46
+ export const singleInput = feature("singleInput", { mfaCandidates }, (p) => p.mfaCandidates === 1);
47
+ export const rect = feature("rect", { field }, (p) => getNodeRect(p.field));
48
+ export const similarBefore = feature("similarBefore", { type, fieldPrev, rect }, (p) => matchSibling(p.fieldPrev, p));
49
+ export const similarAfter = feature("similarAfter", { type, fieldNext, rect }, (p) => matchSibling(p.fieldNext, p));
50
+ export const siblingOfInterest = feature("siblingOfInterest", { similarBefore, similarAfter }, (p) => p.similarBefore || p.similarAfter);
51
+ export const attrOTP = feature("attrOTP", { fieldAttrs }, (p) => any(matchOtpAttr)(p.fieldAttrs));
52
+ export const attrMFA = feature("attrMFA", { fieldAttrs }, (p) => any(matchTwoFa)(p.fieldAttrs));
53
+ export const attrOutlier = feature("attrOutlier", { fieldAttrs }, (p) => any(matchOtpFieldOutlier)(p.fieldAttrs));
54
+ export const textOTP = feature("textOTP", { fieldText }, (p) => matchOtpAttr(p.fieldText));
55
+ export const textMFA = feature("textMFA", { fieldText }, (p) => matchTwoFa(p.fieldText));
56
+ export const textAuthenticator = feature("textAuthenticator", { fieldText }, (p) => matchAuthenticator(p.fieldText));
57
+ export const labelOTP = feature("labelOTP", { fieldLabel }, (p) => matchOtpAttr(p.fieldLabel));
58
+ export const labelMFA = feature("labelMFA", { fieldLabel }, (p) => matchTwoFa(p.fieldLabel));
59
+ export const labelAuthenticator = feature("labelAuthenticator", { fieldLabel }, (p) => matchAuthenticator(p.fieldLabel));
60
+ export const labelOutlier = feature("labelOutlier", { fieldLabel }, (p) => matchOtpFieldOutlier(p.fieldLabel));
61
+ export const mfa = feature("mfa", { formMFA, labelMFA, textMFA, attrMFA }, (p) => p.formMFA || p.labelMFA || p.textMFA || p.attrMFA);
62
+ export const otp = feature("otp", { attrOTP, textOTP, labelOTP }, (p) => p.attrOTP || p.textOTP || p.labelOTP);
63
+ export const outlierCandidate = feature("outlierCandidate", { mfa, otp }, (p) => p.mfa || p.otp);
64
+ export const outlierMaxLength = feature("outlierMaxLength", { maxLen }, (p) => Boolean(p.maxLen && (p.maxLen > 20 || (p.maxLen > 1 && p.maxLen < 5))));
65
+ export const outlierInputCount = feature("outlierInputCount", { mfaCandidates }, (p) => !(p.mfaCandidates === 1 || p.mfaCandidates === 6 || p.mfaCandidates === 5));
66
+ export const outlierEmailMatchRaw = feature("outlierEmailMatch", { outlierCandidate, fieldForm }, (p) => {
67
67
  var _a, _b, _c, _d;
68
- if (!outlierCandidate)
68
+ if (!p.outlierCandidate)
69
69
  return 0;
70
70
  return (_d = (_c = ((_b = (_a = p.fieldForm) === null || _a === void 0 ? void 0 : _a.element.innerText) !== null && _b !== void 0 ? _b : "").match(/[a-z0-9*._-]@/gi)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
71
71
  });
72
- const outlierEmailMatchScaled = featureScaled(outlierEmailMatchRaw, 0, 2);
73
- const outlierField = feature("outlierField", { attrOutlier, labelOutlier, fieldPlaceholder: placeholder }, (p) => p.attrOutlier || p.labelOutlier || p.placeholder.includes("://"));
74
- const outlierSearch = feature("outlierSearch", { isSearchField: fieldSearch, searchForm }, (p) => p.isSearchField || p.searchForm);
75
- const outlierAutocomplete = feature("outlierAutocomplete", { outlierCandidate, autocompleteOff, autocompleteOTC, fieldAutocomplete }, (p) => p.outlierCandidate && p.fieldAutocomplete !== undefined && !p.autocompleteOff && !p.autocompleteOTC);
72
+ export const outlierEmailMatchScaled = featureScaled(outlierEmailMatchRaw, 0, 2);
73
+ export const outlierField = feature("outlierField", { attrOutlier, labelOutlier, fieldPlaceholder: placeholder }, (p) => p.attrOutlier || p.labelOutlier || p.placeholder.includes("://"));
74
+ export const outlierSearch = feature("outlierSearch", { isSearchField: fieldSearch, searchForm }, (p) => p.isSearchField || p.searchForm);
75
+ export const outlierAutocomplete = feature("outlierAutocomplete", { outlierCandidate, autocompleteOff, autocompleteOTC, fieldAutocomplete }, (p) => p.outlierCandidate && p.fieldAutocomplete !== undefined && !p.autocompleteOff && !p.autocompleteOTC);
76
76
  export const otpFeatures = flattenFeatures({
77
77
  attrMFA,
78
78
  attrOTP,