@protontech/autofill 0.0.35059265 → 0.0.36026908
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/features/feature.d.ts +13 -2
- package/features/feature.js +37 -15
- package/features/v1/abstract.field.d.ts +8406 -435
- package/features/v1/abstract.field.js +24 -24
- package/features/v1/abstract.form.d.ts +3428 -14
- package/features/v1/abstract.form.js +197 -197
- package/features/v1/field-predicates.d.ts +8 -0
- package/features/v1/field-predicates.js +42 -0
- package/features/v1/field.email.d.ts +3445 -24
- package/features/v1/field.email.js +7 -7
- package/features/v1/field.otp.d.ts +71234 -56
- package/features/v1/field.otp.js +42 -42
- package/features/v1/field.password.d.ts +99230 -64
- package/features/v1/field.password.js +42 -42
- package/features/v1/field.username-hidden.d.ts +932 -24
- package/features/v1/field.username-hidden.js +7 -7
- package/features/v1/field.username.d.ts +42410 -28
- package/features/v1/field.username.js +11 -11
- package/features/v1/fields.sorted.gen.d.ts +1441 -0
- package/features/v1/fields.sorted.gen.js +344 -0
- package/features/v1/forms.sorted.gen.d.ts +734 -0
- package/features/v1/forms.sorted.gen.js +334 -0
- package/features/v1/index.d.ts +5305 -12
- package/features/v1/index.js +7 -11
- package/models/perceptron/params/email-model.json +4 -4
- package/models/perceptron/params/login-model.json +97 -97
- package/models/perceptron/params/new-password-model.json +16 -16
- package/models/perceptron/params/otp-model.json +29 -29
- package/models/perceptron/params/password-change-model.json +69 -69
- package/models/perceptron/params/password-model.json +18 -18
- package/models/perceptron/params/recovery-model.json +92 -92
- package/models/perceptron/params/register-model.json +90 -90
- package/models/perceptron/params/username-hidden-model.json +7 -7
- package/models/perceptron/params/username-model.json +3 -3
- package/models/random_forest/params/otp-model.json +306 -366
- package/package.json +3 -3
- package/rules/v1/index.js +5 -5
- package/types/index.d.ts +2 -1
- package/utils/credit-card.d.ts +0 -1
- package/utils/credit-card.js +2 -9
- package/utils/fathom.d.ts +1 -2
- package/utils/fathom.js +2 -2
- package/utils/field.d.ts +4 -5
- package/utils/field.js +6 -17
- package/utils/identity.d.ts +0 -2
- package/utils/identity.js +2 -23
- package/dictionary/generate.d.ts +0 -1
- package/dictionary/generate.js +0 -51
- package/features/feature.spec.d.ts +0 -1
- package/features/feature.spec.js +0 -59
- package/features/registry.d.ts +0 -3
- package/features/registry.js +0 -9
- package/features/sorted.gen.d.ts +0 -14
- package/features/sorted.gen.js +0 -22
- package/features/v1/index.spec.d.ts +0 -1
- package/features/v1/index.spec.js +0 -30
- package/scripts/gen-sorted-features.d.ts +0 -1
- package/scripts/gen-sorted-features.js +0 -32
- package/utils/credit-card.samples.spec.d.ts +0 -1
- package/utils/credit-card.samples.spec.js +0 -452
- package/utils/credit-card.spec.d.ts +0 -1
- package/utils/credit-card.spec.js +0 -296
- package/utils/identity.samples.spec.d.ts +0 -1
- package/utils/identity.samples.spec.js +0 -28
- package/utils/re.spec.d.ts +0 -1
- package/utils/re.spec.js +0 -62
- package/utils/shadow-dom.spec.d.ts +0 -1
- package/utils/shadow-dom.spec.js +0 -215
package/features/feature.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AbstractFeature, AbstractFeatures, Feature, FeatureComputer, InferFeatureName, InferFeatureReturnType, InferParentComputeType } from "@protontech/autofill/types";
|
|
2
2
|
import type { Fnode } from "@protontech/fathom";
|
|
3
|
-
export declare const feature: <N extends string, R, P extends AbstractFeatures>(name: N, parents: P, compute: (parents: InferParentComputeType<P>, fnode: Fnode) => R
|
|
3
|
+
export declare const feature: <N extends string, R, P extends AbstractFeatures>(name: N, parents: P, compute: (parents: InferParentComputeType<P>, fnode: Fnode) => R, opts?: {
|
|
4
|
+
private?: true;
|
|
5
|
+
}) => Feature<N, R, P>;
|
|
4
6
|
export declare const featureCount: <N extends string, R extends unknown[], P extends AbstractFeatures>(feat: Feature<N, R, P>) => Feature<`${N}Count`, number, {
|
|
5
7
|
[x: string]: Feature<N, R, P>;
|
|
6
8
|
}>;
|
|
@@ -12,7 +14,16 @@ type FlatFeatures<F extends AbstractFeatures> = {
|
|
|
12
14
|
[K in keyof F]: FlatFeature<F[K]>;
|
|
13
15
|
};
|
|
14
16
|
export declare const flattenFeatures: <F extends AbstractFeatures>(features: F) => FlatFeatures<F>;
|
|
15
|
-
export declare const getComputerForFeatures: (sorted
|
|
17
|
+
export declare const getComputerForFeatures: <F extends AbstractFeatures>({ sorted, features, private: privateFeatures }: {
|
|
18
|
+
sorted: readonly AbstractFeature[];
|
|
19
|
+
features: readonly string[];
|
|
20
|
+
private: readonly string[];
|
|
21
|
+
}) => FeatureComputer<FlatFeatures<F>>;
|
|
22
|
+
export declare const validateComputerInputs: ({ sorted, features, private: privateFeatures }: {
|
|
23
|
+
sorted: readonly AbstractFeature[];
|
|
24
|
+
features: readonly string[];
|
|
25
|
+
private: readonly string[];
|
|
26
|
+
}) => void;
|
|
16
27
|
export declare const topologicalSort: (features: AbstractFeatures) => AbstractFeature<unknown>[];
|
|
17
28
|
export declare const computeFeatures: <F extends AbstractFeatures>(featureComputer: FeatureComputer<F>, fnode: Fnode) => import("@protontech/autofill/types").ComputedFeatures<F>;
|
|
18
29
|
export {};
|
package/features/feature.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { utils } from "@protontech/fathom";
|
|
2
2
|
const { linearScale } = utils;
|
|
3
|
-
export const feature = (name, parents, compute) => ({
|
|
3
|
+
export const feature = (name, parents, compute, opts) => ({
|
|
4
4
|
name,
|
|
5
5
|
parents,
|
|
6
6
|
compute,
|
|
7
|
+
...(opts !== null && opts !== void 0 ? opts : {}),
|
|
7
8
|
});
|
|
8
9
|
export const featureCount = (feat) => feature(`${feat.name}Count`, { [feat.name]: feat }, (parents) => parents[feat.name].length);
|
|
9
10
|
export const featureScaled = (feat, min, max) => feature(`${feat.name}Scaled`, { [feat.name]: feat }, (parents) => linearScale(parents[feat.name], min, max));
|
|
@@ -16,17 +17,35 @@ export const featuresProduct = (feat1, feat2) => feature(`${feat1.name},${feat2.
|
|
|
16
17
|
[feat2.name]: feat2,
|
|
17
18
|
}, (parents) => Number(parents[feat1.name]) * Number(parents[feat2.name]));
|
|
18
19
|
export const flattenFeatures = (features) => features;
|
|
19
|
-
export const getComputerForFeatures = (sorted,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
export const getComputerForFeatures = ({ sorted, features, private: privateFeatures }) => ({
|
|
21
|
+
compute: (fnode) => {
|
|
22
|
+
const parents = {};
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const feature of sorted)
|
|
25
|
+
parents[feature.name] = feature.compute(parents, fnode);
|
|
26
|
+
for (const name of features)
|
|
27
|
+
result[name] = parents[name];
|
|
28
|
+
for (const name of privateFeatures)
|
|
29
|
+
result[name] = parents[name];
|
|
30
|
+
return result;
|
|
31
|
+
},
|
|
32
|
+
features,
|
|
33
|
+
});
|
|
34
|
+
export const validateComputerInputs = ({ sorted, features, private: privateFeatures }) => {
|
|
35
|
+
const computed = new Set();
|
|
36
|
+
for (const f of sorted) {
|
|
37
|
+
if (computed.has(f.name))
|
|
38
|
+
throw new Error(`duplicate feature '${f.name}' in sorted DAG`);
|
|
39
|
+
for (const p of Object.values(f.parents)) {
|
|
40
|
+
if (!computed.has(p.name))
|
|
41
|
+
throw new Error(`feature '${f.name}' precedes its parent '${p.name}' in sorted DAG`);
|
|
42
|
+
}
|
|
43
|
+
computed.add(f.name);
|
|
44
|
+
}
|
|
45
|
+
for (const name of [...features, ...privateFeatures]) {
|
|
46
|
+
if (!computed.has(name))
|
|
47
|
+
throw new Error(`output '${name}' missing from sorted DAG`);
|
|
48
|
+
}
|
|
30
49
|
};
|
|
31
50
|
export const topologicalSort = (features) => {
|
|
32
51
|
var _a;
|
|
@@ -43,8 +62,10 @@ export const topologicalSort = (features) => {
|
|
|
43
62
|
else {
|
|
44
63
|
Object.values(node.parents).forEach((parent) => {
|
|
45
64
|
var _a, _b, _c, _d;
|
|
46
|
-
if (!seen.has(parent))
|
|
65
|
+
if (!seen.has(parent)) {
|
|
47
66
|
to_visit.push(parent);
|
|
67
|
+
seen.add(parent);
|
|
68
|
+
}
|
|
48
69
|
(_b = (_a = childToParents.get(node)) === null || _a === void 0 ? void 0 : _a.add(parent)) !== null && _b !== void 0 ? _b : childToParents.set(node, new Set([parent]));
|
|
49
70
|
(_d = (_c = parentToChildren.get(parent)) === null || _c === void 0 ? void 0 : _c.add(node)) !== null && _d !== void 0 ? _d : parentToChildren.set(parent, new Set([node]));
|
|
50
71
|
});
|
|
@@ -65,10 +86,11 @@ export const topologicalSort = (features) => {
|
|
|
65
86
|
sorted.push(node);
|
|
66
87
|
}
|
|
67
88
|
if (childToParents.size > 0) {
|
|
68
|
-
throw new Error(`loop detected with elements:\n ${Array.from(childToParents.entries()
|
|
89
|
+
throw new Error(`loop detected with elements:\n ${Array.from(childToParents.entries())
|
|
90
|
+
.map(([child, parents]) => `${child.name} -> {${Array.from(parents)
|
|
69
91
|
.map((parent) => parent.name)
|
|
70
92
|
.sort()
|
|
71
|
-
.join(", ")}}`)
|
|
93
|
+
.join(", ")}}`)
|
|
72
94
|
.sort()
|
|
73
95
|
.join("\n ")}`);
|
|
74
96
|
}
|