@protontech/autofill 0.0.22991789
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.
- package/README.md +1 -0
- package/cli.d.ts +2 -0
- package/cli.js +128 -0
- package/constants/heuristics.d.ts +15 -0
- package/constants/heuristics.js +21 -0
- package/constants/selectors.d.ts +18 -0
- package/constants/selectors.js +52 -0
- package/debug.d.ts +1 -0
- package/debug.js +17 -0
- package/dictionary/generate.d.ts +1 -0
- package/dictionary/generate.js +42 -0
- package/dictionary/generated/dictionary.d.ts +51 -0
- package/dictionary/generated/dictionary.js +51 -0
- package/dictionary/source/dictionary.d.ts +11 -0
- package/dictionary/source/dictionary.js +375 -0
- package/dictionary/source/patterns.d.ts +3 -0
- package/dictionary/source/patterns.js +3 -0
- package/features/abstract.field.d.ts +123 -0
- package/features/abstract.field.js +63 -0
- package/features/abstract.form.d.ts +98 -0
- package/features/abstract.form.js +281 -0
- package/features/field.email.d.ts +18 -0
- package/features/field.email.js +43 -0
- package/features/field.otp.d.ts +36 -0
- package/features/field.otp.js +116 -0
- package/features/field.password.d.ts +35 -0
- package/features/field.password.js +104 -0
- package/features/field.username-hidden.d.ts +15 -0
- package/features/field.username-hidden.js +40 -0
- package/features/field.username.d.ts +16 -0
- package/features/field.username.js +41 -0
- package/features/form.combined.d.ts +1 -0
- package/features/form.combined.js +6 -0
- package/index.d.ts +14 -0
- package/index.js +15 -0
- package/package.json +29 -0
- package/rulesets.d.ts +2 -0
- package/rulesets.js +10 -0
- package/trainees/field.email.d.ts +2 -0
- package/trainees/field.email.js +16 -0
- package/trainees/field.identity.d.ts +2 -0
- package/trainees/field.identity.js +9 -0
- package/trainees/field.otp.d.ts +2 -0
- package/trainees/field.otp.js +16 -0
- package/trainees/field.password.current.d.ts +2 -0
- package/trainees/field.password.current.js +16 -0
- package/trainees/field.password.new.d.ts +2 -0
- package/trainees/field.password.new.js +16 -0
- package/trainees/field.username-hidden.d.ts +2 -0
- package/trainees/field.username-hidden.js +22 -0
- package/trainees/field.username.d.ts +2 -0
- package/trainees/field.username.js +16 -0
- package/trainees/form.login.d.ts +2 -0
- package/trainees/form.login.js +16 -0
- package/trainees/form.noop.d.ts +1 -0
- package/trainees/form.noop.js +7 -0
- package/trainees/form.password-change.d.ts +2 -0
- package/trainees/form.password-change.js +16 -0
- package/trainees/form.recovery.d.ts +2 -0
- package/trainees/form.recovery.js +16 -0
- package/trainees/form.register.d.ts +2 -0
- package/trainees/form.register.js +16 -0
- package/trainees/index.d.ts +9 -0
- package/trainees/index.js +72 -0
- package/trainees/results/result.email.d.ts +2 -0
- package/trainees/results/result.email.js +17 -0
- package/trainees/results/result.login.d.ts +2 -0
- package/trainees/results/result.login.js +110 -0
- package/trainees/results/result.new-password.d.ts +2 -0
- package/trainees/results/result.new-password.js +36 -0
- package/trainees/results/result.otp.d.ts +2 -0
- package/trainees/results/result.otp.js +43 -0
- package/trainees/results/result.password-change.d.ts +2 -0
- package/trainees/results/result.password-change.js +110 -0
- package/trainees/results/result.password.d.ts +2 -0
- package/trainees/results/result.password.js +36 -0
- package/trainees/results/result.recovery.d.ts +2 -0
- package/trainees/results/result.recovery.js +110 -0
- package/trainees/results/result.register.d.ts +2 -0
- package/trainees/results/result.register.js +110 -0
- package/trainees/results/result.username-hidden.d.ts +2 -0
- package/trainees/results/result.username-hidden.js +15 -0
- package/trainees/results/result.username.d.ts +2 -0
- package/trainees/results/result.username.js +16 -0
- package/types/index.d.ts +38 -0
- package/types/index.js +20 -0
- package/utils/attributes.d.ts +9 -0
- package/utils/attributes.js +13 -0
- package/utils/clustering.d.ts +1 -0
- package/utils/clustering.js +81 -0
- package/utils/combinators.d.ts +6 -0
- package/utils/combinators.js +4 -0
- package/utils/dom.d.ts +25 -0
- package/utils/dom.js +104 -0
- package/utils/exclusion.d.ts +3 -0
- package/utils/exclusion.js +59 -0
- package/utils/extract.d.ts +13 -0
- package/utils/extract.js +59 -0
- package/utils/fathom.d.ts +38 -0
- package/utils/fathom.js +68 -0
- package/utils/field.d.ts +14 -0
- package/utils/field.js +50 -0
- package/utils/flags.d.ts +25 -0
- package/utils/flags.js +60 -0
- package/utils/form.d.ts +7 -0
- package/utils/form.js +25 -0
- package/utils/identity.d.ts +24 -0
- package/utils/identity.js +63 -0
- package/utils/memoize.d.ts +5 -0
- package/utils/memoize.js +12 -0
- package/utils/prepass.d.ts +2 -0
- package/utils/prepass.js +31 -0
- package/utils/re.d.ts +58 -0
- package/utils/re.js +64 -0
- package/utils/text.d.ts +3 -0
- package/utils/text.js +8 -0
- package/utils/visible.d.ts +13 -0
- package/utils/visible.js +143 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { any } from "../utils/combinators";
|
|
2
|
+
import { boolInt } from "../utils/fathom";
|
|
3
|
+
import { matchEmailAttr, matchEmailValue, matchTelValue, matchUsernameAttr, matchUsernameValue } from "../utils/re";
|
|
4
|
+
import { isVisible } from "../utils/visible";
|
|
5
|
+
const getHiddenUserFieldFeatures = (fnode) => {
|
|
6
|
+
const field = fnode.element;
|
|
7
|
+
const fieldFeatures = fnode.noteFor("field");
|
|
8
|
+
const { fieldAttrs, autocomplete } = fieldFeatures;
|
|
9
|
+
const attrUsername = any(matchUsernameAttr)(fieldAttrs);
|
|
10
|
+
const attrEmail = any(matchEmailAttr)(fieldAttrs);
|
|
11
|
+
const usernameAttr = field.matches('[name="username"],[id="username"]');
|
|
12
|
+
const autocompleteUsername = autocomplete === "username";
|
|
13
|
+
const visibleReadonly = field.readOnly && isVisible(field, { opacity: true }) && field.type !== "hidden";
|
|
14
|
+
const valueEmail = matchEmailValue(fieldFeatures.value);
|
|
15
|
+
const valueTel = matchTelValue(fieldFeatures.value);
|
|
16
|
+
const valueUsername = matchUsernameValue(fieldFeatures.value);
|
|
17
|
+
return {
|
|
18
|
+
exotic: boolInt(fieldFeatures.isFormNoop),
|
|
19
|
+
attrUsername: boolInt(attrUsername),
|
|
20
|
+
attrEmail: boolInt(attrEmail),
|
|
21
|
+
usernameAttr: boolInt(usernameAttr),
|
|
22
|
+
autocompleteUsername: boolInt(autocompleteUsername),
|
|
23
|
+
visibleReadonly: boolInt(visibleReadonly),
|
|
24
|
+
hiddenEmailValue: boolInt(valueEmail),
|
|
25
|
+
hiddenTelValue: boolInt(valueTel),
|
|
26
|
+
hiddenUsernameValue: boolInt(valueUsername),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default getHiddenUserFieldFeatures;
|
|
30
|
+
export const HIDDEN_USER_FIELD_FEATURES = [
|
|
31
|
+
"exotic",
|
|
32
|
+
"attrUsername",
|
|
33
|
+
"attrEmail",
|
|
34
|
+
"usernameAttr",
|
|
35
|
+
"autocompleteUsername",
|
|
36
|
+
"visibleReadonly",
|
|
37
|
+
"hiddenEmailValue",
|
|
38
|
+
"hiddenTelValue",
|
|
39
|
+
"hiddenUsernameValue",
|
|
40
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Fnode } from "@protontech/fathom";
|
|
2
|
+
declare const getUsernameFieldFeatures: (fnode: Fnode) => {
|
|
3
|
+
autocompleteUsername: number;
|
|
4
|
+
autocompleteNickname: number;
|
|
5
|
+
autocompleteEmail: number;
|
|
6
|
+
autocompleteOff: number;
|
|
7
|
+
attrUsername: number;
|
|
8
|
+
textUsername: number;
|
|
9
|
+
labelUsername: number;
|
|
10
|
+
outlierUsername: number;
|
|
11
|
+
loginUsername: number;
|
|
12
|
+
searchField: number;
|
|
13
|
+
};
|
|
14
|
+
export default getUsernameFieldFeatures;
|
|
15
|
+
export type UsernameFieldFeatures = ReturnType<typeof getUsernameFieldFeatures>;
|
|
16
|
+
export declare const USERNAME_FIELD_FEATURES: (keyof UsernameFieldFeatures)[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { any } from "../utils/combinators";
|
|
2
|
+
import { boolInt } from "../utils/fathom";
|
|
3
|
+
import { matchEmailAttr, matchUsername, matchUsernameAttr, matchUsernameOutlier } from "../utils/re";
|
|
4
|
+
const getUsernameFieldFeatures = (fnode) => {
|
|
5
|
+
const fieldFeatures = fnode.noteFor("field");
|
|
6
|
+
const { fieldAttrs, fieldText, labelText, prevField } = fieldFeatures;
|
|
7
|
+
const attrUsername = any(matchUsernameAttr)(fieldAttrs);
|
|
8
|
+
const textUsername = matchUsername(fieldText);
|
|
9
|
+
const labelUsername = matchUsername(labelText);
|
|
10
|
+
const outlierUsername = any(matchUsernameOutlier)(fieldAttrs.concat(fieldText, labelText));
|
|
11
|
+
const haystack = fieldAttrs.concat(fieldText).concat(labelText);
|
|
12
|
+
const outlier = outlierUsername || any(matchEmailAttr)(haystack);
|
|
13
|
+
const loginForm = fieldFeatures.isFormLogin;
|
|
14
|
+
const isFirstField = prevField === null;
|
|
15
|
+
const loginUsername = loginForm && isFirstField && !outlier;
|
|
16
|
+
return {
|
|
17
|
+
autocompleteUsername: boolInt(fieldFeatures.autocomplete === "username"),
|
|
18
|
+
autocompleteNickname: boolInt(fieldFeatures.autocomplete === "nickname"),
|
|
19
|
+
autocompleteEmail: boolInt(fieldFeatures.autocomplete === "email"),
|
|
20
|
+
autocompleteOff: boolInt(fieldFeatures.autocomplete === "off"),
|
|
21
|
+
attrUsername: boolInt(attrUsername),
|
|
22
|
+
textUsername: boolInt(textUsername),
|
|
23
|
+
labelUsername: boolInt(labelUsername),
|
|
24
|
+
outlierUsername: boolInt(outlier),
|
|
25
|
+
loginUsername: boolInt(loginUsername),
|
|
26
|
+
searchField: boolInt(fieldFeatures.searchField),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default getUsernameFieldFeatures;
|
|
30
|
+
export const USERNAME_FIELD_FEATURES = [
|
|
31
|
+
"autocompleteUsername",
|
|
32
|
+
"autocompleteNickname",
|
|
33
|
+
"autocompleteEmail",
|
|
34
|
+
"autocompleteOff",
|
|
35
|
+
"attrUsername",
|
|
36
|
+
"textUsername",
|
|
37
|
+
"labelUsername",
|
|
38
|
+
"outlierUsername",
|
|
39
|
+
"loginUsername",
|
|
40
|
+
"searchField",
|
|
41
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FORM_COMBINED_FEATURES: ("formMFA" | "formOTPOutlier" | "linkOTPOutlier" | "fieldsCount" | "inputCount" | "fieldsetCount" | "textCount" | "textareaCount" | "selectCount" | "optionsCount" | "checkboxCount" | "radioCount" | "identifierCount" | "hiddenIdentifierCount" | "hiddenCount" | "passwordCount" | "hiddenPasswordCount" | "usernameCount" | "emailCount" | "submitCount" | "hasTels" | "hasOAuth" | "hasCaptchas" | "hasFiles" | "hasDate" | "hasNumber" | "oneVisibleField" | "twoVisibleFields" | "threeOrMoreVisibleFields" | "noPasswords" | "onePassword" | "twoPasswords" | "threeOrMorePasswords" | "noIdentifiers" | "oneIdentifier" | "twoIdentifiers" | "threeOrMoreIdentifiers" | "autofocusedIsIdentifier" | "autofocusedIsPassword" | "visibleInputsCount" | "inputRatio" | "hiddenRatio" | "visibleRatio" | "identifierRatio" | "emailRatio" | "usernameRatio" | "passwordRatio" | "checkboxRatio" | "requiredRatio" | "patternRatio" | "minMaxLengthRatio" | "pageLogin" | "formTextLogin" | "formAttrsLogin" | "headingsLogin" | "layoutLogin" | "rememberMeCheckbox" | "troubleLink" | "submitLogin" | "pageRegister" | "formTextRegister" | "formAttrsRegister" | "headingsRegister" | "layoutRegister" | "pwNewRegister" | "pwConfirmRegister" | "submitRegister" | "TOSRef" | "pagePwReset" | "formTextPwReset" | "formAttrsPwReset" | "headingsPwReset" | "layoutPwReset" | "pageRecovery" | "formTextRecovery" | "formAttrsRecovery" | "headingsRecovery" | "layoutRecovery" | "identifierRecovery" | "submitRecovery" | "formTextMFA" | "formAttrsMFA" | "inputsMFA" | "inputsOTP" | "newsletterForm" | "searchForm" | "multiStepForm" | "multiAuthForm" | "formInputIterator" | ["formMFA" | "formOTPOutlier" | "linkOTPOutlier" | "fieldsCount" | "inputCount" | "fieldsetCount" | "textCount" | "textareaCount" | "selectCount" | "optionsCount" | "checkboxCount" | "radioCount" | "identifierCount" | "hiddenIdentifierCount" | "hiddenCount" | "passwordCount" | "hiddenPasswordCount" | "usernameCount" | "emailCount" | "submitCount" | "hasTels" | "hasOAuth" | "hasCaptchas" | "hasFiles" | "hasDate" | "hasNumber" | "oneVisibleField" | "twoVisibleFields" | "threeOrMoreVisibleFields" | "noPasswords" | "onePassword" | "twoPasswords" | "threeOrMorePasswords" | "noIdentifiers" | "oneIdentifier" | "twoIdentifiers" | "threeOrMoreIdentifiers" | "autofocusedIsIdentifier" | "autofocusedIsPassword" | "visibleInputsCount" | "inputRatio" | "hiddenRatio" | "visibleRatio" | "identifierRatio" | "emailRatio" | "usernameRatio" | "passwordRatio" | "checkboxRatio" | "requiredRatio" | "patternRatio" | "minMaxLengthRatio" | "pageLogin" | "formTextLogin" | "formAttrsLogin" | "headingsLogin" | "layoutLogin" | "rememberMeCheckbox" | "troubleLink" | "submitLogin" | "pageRegister" | "formTextRegister" | "formAttrsRegister" | "headingsRegister" | "layoutRegister" | "pwNewRegister" | "pwConfirmRegister" | "submitRegister" | "TOSRef" | "pagePwReset" | "formTextPwReset" | "formAttrsPwReset" | "headingsPwReset" | "layoutPwReset" | "pageRecovery" | "formTextRecovery" | "formAttrsRecovery" | "headingsRecovery" | "layoutRecovery" | "identifierRecovery" | "submitRecovery" | "formTextMFA" | "formAttrsMFA" | "inputsMFA" | "inputsOTP" | "newsletterForm" | "searchForm" | "multiStepForm" | "multiAuthForm" | "formInputIterator", "formMFA" | "formOTPOutlier" | "linkOTPOutlier" | "fieldsCount" | "inputCount" | "fieldsetCount" | "textCount" | "textareaCount" | "selectCount" | "optionsCount" | "checkboxCount" | "radioCount" | "identifierCount" | "hiddenIdentifierCount" | "hiddenCount" | "passwordCount" | "hiddenPasswordCount" | "usernameCount" | "emailCount" | "submitCount" | "hasTels" | "hasOAuth" | "hasCaptchas" | "hasFiles" | "hasDate" | "hasNumber" | "oneVisibleField" | "twoVisibleFields" | "threeOrMoreVisibleFields" | "noPasswords" | "onePassword" | "twoPasswords" | "threeOrMorePasswords" | "noIdentifiers" | "oneIdentifier" | "twoIdentifiers" | "threeOrMoreIdentifiers" | "autofocusedIsIdentifier" | "autofocusedIsPassword" | "visibleInputsCount" | "inputRatio" | "hiddenRatio" | "visibleRatio" | "identifierRatio" | "emailRatio" | "usernameRatio" | "passwordRatio" | "checkboxRatio" | "requiredRatio" | "patternRatio" | "minMaxLengthRatio" | "pageLogin" | "formTextLogin" | "formAttrsLogin" | "headingsLogin" | "layoutLogin" | "rememberMeCheckbox" | "troubleLink" | "submitLogin" | "pageRegister" | "formTextRegister" | "formAttrsRegister" | "headingsRegister" | "layoutRegister" | "pwNewRegister" | "pwConfirmRegister" | "submitRegister" | "TOSRef" | "pagePwReset" | "formTextPwReset" | "formAttrsPwReset" | "headingsPwReset" | "layoutPwReset" | "pageRecovery" | "formTextRecovery" | "formAttrsRecovery" | "headingsRecovery" | "layoutRecovery" | "identifierRecovery" | "submitRecovery" | "formTextMFA" | "formAttrsMFA" | "inputsMFA" | "inputsOTP" | "newsletterForm" | "searchForm" | "multiStepForm" | "multiAuthForm" | "formInputIterator"])[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { combineFeatures } from "../utils/fathom";
|
|
2
|
+
import { FORM_FEATURES } from "./abstract.form";
|
|
3
|
+
export const FORM_COMBINED_FEATURES = [
|
|
4
|
+
...FORM_FEATURES,
|
|
5
|
+
...combineFeatures(["visibleRatio", "identifierRatio", "passwordRatio", "requiredRatio"], ["fieldsCount", "identifierCount", "passwordCount", "hiddenIdentifierCount", "hiddenPasswordCount", "multiStepForm"]),
|
|
6
|
+
];
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * as fathom from "@protontech/fathom";
|
|
2
|
+
export * from "./constants/selectors";
|
|
3
|
+
export * from "./trainees";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./utils/attributes";
|
|
6
|
+
export { getTypeScore } from "./utils/fathom";
|
|
7
|
+
export * from "./utils/field";
|
|
8
|
+
export * from "./utils/flags";
|
|
9
|
+
export * from "./utils/form";
|
|
10
|
+
export * from "./utils/identity";
|
|
11
|
+
export * from "./utils/prepass";
|
|
12
|
+
export * from "./utils/visible";
|
|
13
|
+
export * as rulesets from "./rulesets";
|
|
14
|
+
export declare const clearDetectionCache: () => void;
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { clearVisibilityCache } from "./utils/visible";
|
|
2
|
+
export * as fathom from "@protontech/fathom";
|
|
3
|
+
export * from "./constants/selectors";
|
|
4
|
+
export * from "./trainees";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export * from "./utils/attributes";
|
|
7
|
+
export { getTypeScore } from "./utils/fathom";
|
|
8
|
+
export * from "./utils/field";
|
|
9
|
+
export * from "./utils/flags";
|
|
10
|
+
export * from "./utils/form";
|
|
11
|
+
export * from "./utils/identity";
|
|
12
|
+
export * from "./utils/prepass";
|
|
13
|
+
export * from "./utils/visible";
|
|
14
|
+
export * as rulesets from "./rulesets";
|
|
15
|
+
export const clearDetectionCache = () => clearVisibilityCache();
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@protontech/autofill",
|
|
3
|
+
"version": "0.0.22991789",
|
|
4
|
+
"private": false,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@protontech/fathom": "0.0.22991789",
|
|
7
|
+
"@types/node": "^22.13.4",
|
|
8
|
+
"@types/regexgen": "^1.3.3",
|
|
9
|
+
"commander": "^13.1.0",
|
|
10
|
+
"prettier": "^3.5.1",
|
|
11
|
+
"regexgen": "^1.3.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
15
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
16
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
17
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
18
|
+
"@types/jest": "^29.5.14",
|
|
19
|
+
"jest": "^29.7.0",
|
|
20
|
+
"rollup": "^4.34.6",
|
|
21
|
+
"rollup-plugin-dts": "^6.0.2",
|
|
22
|
+
"tslib": "^2.8.1"
|
|
23
|
+
},
|
|
24
|
+
"license": "MPL-2.0",
|
|
25
|
+
"author": "Edvin Candon <edvin.candon@proton.ch>",
|
|
26
|
+
"contributors": [
|
|
27
|
+
"Guðmundur Heimisson <gudmundur.heimisson@proton.ch>"
|
|
28
|
+
]
|
|
29
|
+
}
|
package/rulesets.d.ts
ADDED
package/rulesets.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import definitions, { rulesetMaker } from "./trainees";
|
|
2
|
+
const trainees = new Map();
|
|
3
|
+
definitions.forEach((definition) => {
|
|
4
|
+
trainees.set(definition.name, {
|
|
5
|
+
coeffs: new Map(definition.coeffs),
|
|
6
|
+
viewportSize: { width: 1200, height: 860 },
|
|
7
|
+
rulesetMaker,
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
export { trainees };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { EMAIL_FIELD_FEATURES } from "../features/field.email";
|
|
3
|
+
import { FieldType } from "../types";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.email";
|
|
6
|
+
export const email = {
|
|
7
|
+
name: FieldType.EMAIL,
|
|
8
|
+
coeffs: EMAIL_FIELD_FEATURES.map((key) => { var _a, _b; return [`email-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `email-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("email-field"), type(FieldType.EMAIL), {}),
|
|
13
|
+
...EMAIL_FIELD_FEATURES.map((key) => rule(type(FieldType.EMAIL), featureScore("email-field", key), { name: `email-${key}` })),
|
|
14
|
+
...outRuleWithCache("field-candidate", FieldType.EMAIL),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FieldType } from "../types";
|
|
3
|
+
import { outRuleWithCache } from "../utils/fathom";
|
|
4
|
+
import { maybeIdentity } from "../utils/identity";
|
|
5
|
+
export const identity = [
|
|
6
|
+
rule(type("field").when(maybeIdentity), type("identity-field"), {}),
|
|
7
|
+
rule(type("identity-field"), type(FieldType.IDENTITY), {}),
|
|
8
|
+
...outRuleWithCache("field-candidate", FieldType.IDENTITY, () => () => true),
|
|
9
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { OTP_FIELD_FEATURES } from "../features/field.otp";
|
|
3
|
+
import { FieldType } from "../types";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.otp";
|
|
6
|
+
export const otp = {
|
|
7
|
+
name: FieldType.OTP,
|
|
8
|
+
coeffs: OTP_FIELD_FEATURES.map((key) => { var _a, _b; return [`otp-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `otp-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("otp-field"), type(FieldType.OTP), {}),
|
|
13
|
+
...OTP_FIELD_FEATURES.map((key) => rule(type(FieldType.OTP), featureScore("otp-field", key), { name: `otp-${key}` })),
|
|
14
|
+
...outRuleWithCache("field-candidate", FieldType.OTP),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FieldType } from "../types";
|
|
3
|
+
import { PW_FIELD_FEATURES } from "../features/field.password";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.password";
|
|
6
|
+
export const password = {
|
|
7
|
+
name: FieldType.PASSWORD_CURRENT,
|
|
8
|
+
coeffs: PW_FIELD_FEATURES.map((key) => { var _a, _b; return [`pw-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `pw-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("password-field"), type(FieldType.PASSWORD_CURRENT), {}),
|
|
13
|
+
...PW_FIELD_FEATURES.map((key) => rule(type(FieldType.PASSWORD_CURRENT), featureScore("password-field", key), { name: `pw-${key}` })),
|
|
14
|
+
...outRuleWithCache("field-candidate", FieldType.PASSWORD_CURRENT),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FieldType } from "../types";
|
|
3
|
+
import { PW_FIELD_FEATURES } from "../features/field.password";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.new-password";
|
|
6
|
+
export const newPassword = {
|
|
7
|
+
name: FieldType.PASSWORD_NEW,
|
|
8
|
+
coeffs: PW_FIELD_FEATURES.map((key) => { var _a, _b; return [`pw[new]-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `pw[new]-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("password-field"), type(FieldType.PASSWORD_NEW), {}),
|
|
13
|
+
...PW_FIELD_FEATURES.map((key) => rule(type(FieldType.PASSWORD_NEW), featureScore("password-field", key), { name: `pw[new]-${key}` })),
|
|
14
|
+
...outRuleWithCache("field-candidate", FieldType.PASSWORD_NEW),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FieldType } from "../types";
|
|
3
|
+
import { HIDDEN_USER_FIELD_FEATURES } from "../features/field.username-hidden";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.username-hidden";
|
|
6
|
+
export const usernameHidden = {
|
|
7
|
+
name: FieldType.USERNAME_HIDDEN,
|
|
8
|
+
coeffs: HIDDEN_USER_FIELD_FEATURES.map((key) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
return [
|
|
11
|
+
`username[hidden]-${key}`,
|
|
12
|
+
(_b = (_a = results.coeffs.find(([feature]) => feature === `username[hidden]-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0,
|
|
13
|
+
];
|
|
14
|
+
}),
|
|
15
|
+
bias: results.bias,
|
|
16
|
+
cutoff: results.cutoff,
|
|
17
|
+
getRules: () => [
|
|
18
|
+
rule(type("username-hidden-field"), type(FieldType.USERNAME_HIDDEN), {}),
|
|
19
|
+
...HIDDEN_USER_FIELD_FEATURES.map((key) => rule(type(FieldType.USERNAME_HIDDEN), featureScore("username-hidden-field", key), { name: `username[hidden]-${key}` })),
|
|
20
|
+
...outRuleWithCache("field-candidate", FieldType.USERNAME_HIDDEN),
|
|
21
|
+
],
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FieldType } from "../types";
|
|
3
|
+
import { USERNAME_FIELD_FEATURES } from "../features/field.username";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.username";
|
|
6
|
+
export const username = {
|
|
7
|
+
name: FieldType.USERNAME,
|
|
8
|
+
coeffs: USERNAME_FIELD_FEATURES.map((key) => { var _a, _b; return [`username-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `username-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("username-field"), type(FieldType.USERNAME), {}),
|
|
13
|
+
...USERNAME_FIELD_FEATURES.map((key) => rule(type(FieldType.USERNAME), featureScore("username-field", key), { name: `username-${key}` })),
|
|
14
|
+
...outRuleWithCache("field-candidate", FieldType.USERNAME),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FORM_COMBINED_FEATURES } from "../features/form.combined";
|
|
3
|
+
import { FormType } from "../types";
|
|
4
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
5
|
+
import { results } from "./results/result.login";
|
|
6
|
+
export const login = {
|
|
7
|
+
name: FormType.LOGIN,
|
|
8
|
+
coeffs: FORM_COMBINED_FEATURES.map((feat) => { var _a, _b; return [`login-${feat}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `login-${feat}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("form"), type(FormType.LOGIN), {}),
|
|
13
|
+
...FORM_COMBINED_FEATURES.map((feat) => rule(type(FormType.LOGIN), featureScore("form", feat), { name: `login-${feat}` })),
|
|
14
|
+
...outRuleWithCache("form-candidate", FormType.LOGIN),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noop: any[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FormType } from "../types";
|
|
3
|
+
import { isNoopForm, outRuleWithCache } from "../utils/fathom";
|
|
4
|
+
export const noop = [
|
|
5
|
+
rule(type("form").when(isNoopForm), type(FormType.NOOP), {}),
|
|
6
|
+
...outRuleWithCache("form-candidate", FormType.NOOP, () => () => true),
|
|
7
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FormType } from "../types";
|
|
3
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
4
|
+
import { results } from "./results/result.password-change";
|
|
5
|
+
import { FORM_COMBINED_FEATURES } from "../features/form.combined";
|
|
6
|
+
export const passwordChange = {
|
|
7
|
+
name: FormType.PASSWORD_CHANGE,
|
|
8
|
+
coeffs: FORM_COMBINED_FEATURES.map((key) => { var _a, _b; return [`pw-change-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `pw-change-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("form"), type(FormType.PASSWORD_CHANGE), {}),
|
|
13
|
+
...FORM_COMBINED_FEATURES.map((key) => rule(type(FormType.PASSWORD_CHANGE), featureScore("form", key), { name: `pw-change-${key}` })),
|
|
14
|
+
...outRuleWithCache("form-candidate", FormType.PASSWORD_CHANGE),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FormType } from "../types";
|
|
3
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
4
|
+
import { results } from "./results/result.recovery";
|
|
5
|
+
import { FORM_COMBINED_FEATURES } from "../features/form.combined";
|
|
6
|
+
export const recovery = {
|
|
7
|
+
name: FormType.RECOVERY,
|
|
8
|
+
coeffs: FORM_COMBINED_FEATURES.map((key) => { var _a, _b; return [`recovery-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `recovery-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("form"), type(FormType.RECOVERY), {}),
|
|
13
|
+
...FORM_COMBINED_FEATURES.map((key) => rule(type(FormType.RECOVERY), featureScore("form", key), { name: `recovery-${key}` })),
|
|
14
|
+
...outRuleWithCache("form-candidate", FormType.RECOVERY),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { rule, type } from "@protontech/fathom";
|
|
2
|
+
import { FormType } from "../types";
|
|
3
|
+
import { featureScore, outRuleWithCache } from "../utils/fathom";
|
|
4
|
+
import { results } from "./results/result.register";
|
|
5
|
+
import { FORM_COMBINED_FEATURES } from "../features/form.combined";
|
|
6
|
+
export const register = {
|
|
7
|
+
name: FormType.REGISTER,
|
|
8
|
+
coeffs: FORM_COMBINED_FEATURES.map((key) => { var _a, _b; return [`register-${key}`, (_b = (_a = results.coeffs.find(([feature]) => feature === `register-${key}`)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0]; }),
|
|
9
|
+
bias: results.bias,
|
|
10
|
+
cutoff: results.cutoff,
|
|
11
|
+
getRules: () => [
|
|
12
|
+
rule(type("form"), type(FormType.REGISTER), {}),
|
|
13
|
+
...FORM_COMBINED_FEATURES.map((key) => rule(type(FormType.REGISTER), featureScore("form", key), { name: `register-${key}` })),
|
|
14
|
+
...outRuleWithCache("form-candidate", FormType.REGISTER),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ruleset } from "@protontech/fathom";
|
|
2
|
+
import { Trainee } from "../types";
|
|
3
|
+
declare const definitions: Trainee[];
|
|
4
|
+
export declare const trainees: {
|
|
5
|
+
forms: Record<string, Trainee>;
|
|
6
|
+
fields: Record<string, Trainee>;
|
|
7
|
+
};
|
|
8
|
+
export declare const rulesetMaker: () => ReturnType<typeof ruleset>;
|
|
9
|
+
export default definitions;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { dom, out, rule, ruleset, type } from "@protontech/fathom";
|
|
2
|
+
import getFormFeatures from "../features/abstract.form";
|
|
3
|
+
import { login } from "./form.login";
|
|
4
|
+
import { passwordChange } from "./form.password-change";
|
|
5
|
+
import { recovery } from "./form.recovery";
|
|
6
|
+
import { register } from "./form.register";
|
|
7
|
+
import { email } from "./field.email";
|
|
8
|
+
import { identity } from "./field.identity";
|
|
9
|
+
import { otp } from "./field.otp";
|
|
10
|
+
import { password } from "./field.password.current";
|
|
11
|
+
import { newPassword } from "./field.password.new";
|
|
12
|
+
import { username } from "./field.username";
|
|
13
|
+
import { usernameHidden } from "./field.username-hidden";
|
|
14
|
+
import { withFnodeEl } from "../utils/fathom";
|
|
15
|
+
import getFieldFeature from "../features/abstract.field";
|
|
16
|
+
import getEmailFieldFeatures from "../features/field.email";
|
|
17
|
+
import getOTPFieldFeatures from "../features/field.otp";
|
|
18
|
+
import getPasswordFieldFeatures from "../features/field.password";
|
|
19
|
+
import getUsernameFieldFeatures from "../features/field.username";
|
|
20
|
+
import getHiddenUserFieldFeatures from "../features/field.username-hidden";
|
|
21
|
+
import { processFieldEffect, processFormEffect } from "../utils/fathom";
|
|
22
|
+
import { isClassifiableField, maybeEmail, maybeHiddenUsername, maybeOTP, maybePassword, maybeUsername } from "../utils/field";
|
|
23
|
+
import { isVisibleForm } from "../utils/visible";
|
|
24
|
+
import { formCandidateSelector } from "../constants/selectors";
|
|
25
|
+
import { isClassifiable } from "../utils/flags";
|
|
26
|
+
import { noop } from "./form.noop";
|
|
27
|
+
const definitions = [login, register, passwordChange, recovery, username, usernameHidden, email, password, newPassword, otp];
|
|
28
|
+
export const trainees = {
|
|
29
|
+
forms: {
|
|
30
|
+
login,
|
|
31
|
+
register,
|
|
32
|
+
passwordChange,
|
|
33
|
+
recovery,
|
|
34
|
+
},
|
|
35
|
+
fields: {
|
|
36
|
+
username,
|
|
37
|
+
usernameHidden,
|
|
38
|
+
email,
|
|
39
|
+
password,
|
|
40
|
+
newPassword,
|
|
41
|
+
otp,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export const rulesetMaker = () => {
|
|
45
|
+
const aggregation = definitions.reduce((acc, curr) => ({
|
|
46
|
+
rules: [...acc.rules, ...curr.getRules()],
|
|
47
|
+
coeffs: [...acc.coeffs, ...curr.coeffs],
|
|
48
|
+
biases: [...acc.biases, [curr.name, curr.bias]],
|
|
49
|
+
}), {
|
|
50
|
+
rules: [
|
|
51
|
+
rule(dom(formCandidateSelector), type("form-candidate"), {}),
|
|
52
|
+
rule(dom("input"), type("field-candidate"), {}),
|
|
53
|
+
rule(type("form-candidate").when(withFnodeEl(isClassifiable)), type("form-element"), {}),
|
|
54
|
+
rule(type("form-element").when(withFnodeEl(isVisibleForm)), type("form").note(getFormFeatures), {}),
|
|
55
|
+
rule(type("form-element"), out("form").through(processFormEffect), {}),
|
|
56
|
+
...noop,
|
|
57
|
+
rule(type("field-candidate").when(isClassifiableField), type("field").note(getFieldFeature), {}),
|
|
58
|
+
rule(type("field").when(maybeUsername), type("username-field").note(getUsernameFieldFeatures), {}),
|
|
59
|
+
rule(type("field").when(maybeHiddenUsername), type("username-hidden-field").note(getHiddenUserFieldFeatures), {}),
|
|
60
|
+
rule(type("field").when(maybeEmail), type("email-field").note(getEmailFieldFeatures), {}),
|
|
61
|
+
rule(type("field").when(maybePassword), type("password-field").note(getPasswordFieldFeatures), {}),
|
|
62
|
+
rule(type("field").when(maybeOTP), type("otp-field").note(getOTPFieldFeatures), {}),
|
|
63
|
+
...identity,
|
|
64
|
+
rule(type("field"), out("field").through(processFieldEffect), {}),
|
|
65
|
+
],
|
|
66
|
+
coeffs: [],
|
|
67
|
+
biases: [],
|
|
68
|
+
});
|
|
69
|
+
const rules = ruleset(aggregation.rules, aggregation.coeffs, aggregation.biases);
|
|
70
|
+
return rules;
|
|
71
|
+
};
|
|
72
|
+
export default definitions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const results = {
|
|
2
|
+
bias: -11.64561653137207,
|
|
3
|
+
coeffs: [
|
|
4
|
+
["email-autocompleteUsername", 0.707680881023407],
|
|
5
|
+
["email-autocompleteNickname", 0.2502567768096924],
|
|
6
|
+
["email-autocompleteEmail", 3.4200122356414795],
|
|
7
|
+
["email-typeEmail", 20.136024475097656],
|
|
8
|
+
["email-exactAttrEmail", 20.156497955322266],
|
|
9
|
+
["email-attrEmail", -0.03418790176510811],
|
|
10
|
+
["email-textEmail", 19.176666259765625],
|
|
11
|
+
["email-labelEmail", 22.481016159057617],
|
|
12
|
+
["email-placeholderEmail", 3.798909902572632],
|
|
13
|
+
["email-searchField", -19.822532653808594],
|
|
14
|
+
["email-identityField", -15.00598430633545],
|
|
15
|
+
],
|
|
16
|
+
cutoff: 0.5,
|
|
17
|
+
};
|