
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
user-properties
Advanced tools
Library that help enforce user field properties.
More specifically, it is meant to retrieve implementation properties based on more fundamental ones.
I intend to use it to improve the flexibility, API quality and overall design of the user-store and express-user-local projects.
[1] Later versions should also work. If you find it not to be the case, let me know.
npm install user-properties
In the directory where the module is located, run the following 2 commands on the prompt:
The library takes an object as input and returns a schema object.
The object should have the following structure:
{'Field1': <Field1Properties>, 'Field2': <Field2Properties>, ..., 'FieldN': <FieldnProperties>}
The properties of each field are as follow:
Pass 'Value' to the 'Parse' property of 'Field' and returns the result.
Pass 'Value' to the 'Stringify' property of 'Field' and returns the result.
Returns true if 'Value' returns true when passed to the 'Descriptor' of 'Field', else it returns false.
If 'Parse' is true, the return value of the 'Parse' method with 'Value' as its argument is passed to the 'Descriptor' of 'Field' instead.
Return all fields that are not present in 'Set'.
Returns an array of all fields that are hashable (not Retrievable and Privacy is not Public)
Returns an array of all fields that are suitable to login the user with (Required, Unique and Privacy is not Public). If the 'Source' argument is definedm Access===Source is also a requirement.
Returns an array of all fields that are suitable to authentify a given source (Private, Required, Privacy is Secret. If 'Source' is defined, Access===Source is also a requirement)
Returns an array of all fields that are suitable to uniquely identify a user (Required and Unique)
Returns an array of all fields whose defined by 'Property' is equal to the value defined by 'Value'. If no arguments are passed, all fields are returned.
Returns an array of all the fields that are modifiable (Mutable). If 'Source' is defined, Access===Source is also a requirement.
Returns an array of all elements present in both SetA and SetB.
Returns an array of all elements present in at least one of SetA or SetB.
Returns an array of all fields where 'Property' is an array-like container (ie, needs to have the 'some' method defined) which contains the value 'Value'.
Returns an array of all fields where an automated value could be generated after the field is initially created. This requires both 'Auto' to be listed in the field's Sources and the field to be mutable.
Calls the Generator property to generate a value for the field. The Callback is optional.
If Callback is undefined, the Generate method will assume that the field's Generator property is a synchronous function and return its result.
If Callback is defined, the Generate method will pass it as an argument to the Generator. If the Field doesn't have a Generator, the Generate method will call Callback directly, passing it an error as it's first argument and null as its second.
Returns true if 'Property' of 'Field' is an array and contains 'Value', else returns false.
Returns true if 'Property' of 'Field' is strictly equal (===) to 'Value', else returns false.
Variation on the above call, where 'Properties' is an object whose property/value pairs represent properties/values to test in 'Field'.
I highly recommend you take a look at the test file to see how this library should be use.
The test file handles the classical case of a user that has the following fields: Username, Email, Password, Gender, Age and EmailToken.
Potential new calls/properties as I find use for them
Fixed markeup error in doc.
Added 'GenAccess' and 'GenIntersection' methods.
Added GenComplement method.
Added GenAll method.
Initial Release
FAQs
Utility to help enforce field properties for users
We found that user-properties demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.