0.9.1 • Published 4 years ago
wasmlibfp v0.9.1
wasmlibfp
The WASM target for the libfp
project
Getting Started
You can install wasmlibfp
using npm:
npm install --save wasmlibfp
Once wasmlibfp
is in your project, you can start fingerprinting data.
import * as libfp from "wasmlibfp";
const source_string = " Thi!@s is S0om3e broken te3xt ";
const cleaned = libfp.clean_string(source_string);
console.log(cleaned); // should print: " THIS IS SOME BROKEN TEXT "
const email = "test@example.org";
const field = JSON.parse(libfp.field_from_email("label", email));
console.log(field.variants); // should print an array of arrays containing two fingerprints.
API
The available API is:
// general functions (not used often)
clean_string(source: string): string;
fingerprint_chunk(source: string): string;
fingerprint(source: string, mode: int, tiled: bool): array;
fingerprint_email(source: string): string;
fingerprint_email_from_sha1(source: string): string;
fingerprint_email_sha1(source: string): string
// field functions (all return stringified JSON)
field_from_name(label: string, first_name: string, middle_name: string, last_name: string): string;
field_from_address(label: string, address: string): string;
field_from_region(label: string, city: string, province: string, postal_code: string): string;
field_from_phone(label: string, phone: string): string;
field_from_ssn(label: string, ssn: string): string;
field_from_email(label: string, email: string): string;
The stringifed JSON structure for a field is:
{
"label": "field_label",
"field_type": "email|phone|name|ssn|address|region",
"variants": [
[ "fingerprints", "representing", "a single", "variant" ],
[ "fingerprints", "representing", "another", "variant" ]
]
}