PINs¶
The PINs of a given token are retrieved using the Token.pins
property. They can then be manipulated using the methods described below.
- class SCWS.Pin()¶
Represents a PIN that protects smart card contents.
- Pin.token¶
The
SCWS.Token()
object this PIN belongs to.
- Pin.label¶
The PIN label. Can be undefined if the card has a single PIN without explicit label defined.
- Pin.initialized¶
Boolean indicating if the PIN has been initialized.
- Pin.toBeChanged¶
Boolean indicating if the PIN need to be changed before use.
- Pin.blocked¶
Boolean indicating if the PIN is blocked.
- Pin.tryCountLow¶
Boolean indicating if the PIN try counter is lower than the maximum (an unsuccessful verification attempt has been made).
- Pin.lastTry¶
Boolean indicating if the PIN try counter shows only one attempt remaining.
- Pin.remainingTries¶
Number of remaining tries for the PIN verification. Can be undefined if the information is unavailable.
- Pin.validated¶
Boolean indicating if the PIN has been successfully verified (access to the private objects is granted).
- Pin.initSubmissionsState¶
SCWS.CredentialState()
object which can be used during alogin()
process in order to update the remaining PIN tries and a potential error informations in the PIN dialog.
- Pin.credentialProperties¶
Javascript object containing PIN properties, with the following fields:
pinLabel
: The pin label as a string.methods
: The supported methods by the corresponding slot, as a Javascript object. This object has itself the following fields:facialBio
: Boolean indicating if facial biometry is supported. Iftrue
and supported on this platform, a facial biometry verification can be done throughPin.requestCredential()
.fingerBio
: Boolean indicating if fingerprint biometry is supported. Iftrue
and supported on this platform, a fingerprint biometry verification can be done throughPin.requestCredential()
.fingerBioIsOneToManySupported
: Boolean indicating if fingerprint one to many match on card is supported by the token. This value is used only iffingerBio
equalstrue
.
- Pin.requestCredential(credentialProperties, credentialState, readerName, cardLabel)¶
Displays a standalone PIN dialog that allows the user to set the PIN or use biometry process, in order to get the necessary credential for a
login()
process.If a secure biometric reader (SBR2 reader) is used for fingerprint verification,
credentialProperties
parameter must be created usingPin.credentialProperties
from a validSCWS.Pin()
object. The correspondingSCWS.Token()
must exist and be available. This feature is available from middleware version6.23.1.0
.- Arguments:
credentialProperties – the
credential properties
as a Javascript object. If a token has been read previously, value ofPin.credentialProperties
can be used from a specificSCWS.Pin()
object. If no token has been read before opening the PIN dialog, this parameter can be build respectingPin.credentialProperties
format.credentialState – the
SCWS.CredentialState()
object which displays the current credential state (remaining tries, a potential error…) in the PIN dialog.readerName – the current
readerName
. Optional.cardLabel – the current
cardLabel
. Optional.
- Returns:
A Promise resolving to a
SCWS.CredentialValue()
object. This object can be directlty used inPin.login()
operation. If requesting credential is cancelled by the user, resolved value isundefined
. If an error occured while requesting credential, returned Promise is rejected with aSCWS.Error()
.
Examples:
// Use case 1: A token has been read and a PIN dialog is used to get `CredentialValue` object. // we assume `pin` object is correctly set var state = pin.initSubmissionsState; pin.requestCredential( pin.credentialProperties, state, pin.token.reader.name, pin.token.label).then(function(credential) { pin.login(credential).then(function() { console.log("Login successful"); }); } ); // Use case 2: No token has been read and a PIN dialog is used to get `CredentialValue` object. // User creates the pinProperties object in order to display the wanted informations in the PIN dialog var pinProperties = { pinLabel: "...", methods: { facialBio: false, fingerBio: false } }; var readerName = "My reader name"; var cardLabel = "My card label"; var state = new SCWS.CredentialState(); SCWS.Pin.prototype.requestCredential( pinProperties, state, readerName, cardLabel).then(function(credential) { // ... // ask the user to present a card if needed // we assume a `pin` object has been retrieved from connected token pin.login(credential).then(function() { console.log("Login successful"); }); } );
- Pin.startAutoLogin(counter)¶
Starts a PIN cache session.
On the next call to
SCWS.Pin.login()
withfalse
value, the value of the PIN will be saved for use on subsequent calls.Signatures with non-repudiable keys (see
SCWS.Key.alwaysAuthenticate
) throughSCWS.Key.sign()
andSCWS.Key.hashAndSign()
can also be repeated without an explicit call toSCWS.Pin.login()
. In this case, the login will be made implicitly if the user is no longer logged in.This feature is available from
6.23.21.0
middleware version.- Arguments:
counter – (optional) Maximum number of signatures accepted in the session. When this number is reached, the PIN value is removed from the cache. On the next call to
SCWS.Pin.login()
, the value of the PIN will not be saved.
- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.stopAutoLogin()¶
Stops a PIN cache session.
The value of the PIN is removed from the cache. From this point, an explicit call to
SCWS.Pin.login()
is required before any signature.On the next call to
SCWS.Pin.login()
withfalse
value parameter, the PIN value will not be saved anymore.This feature is available from
6.23.21.0
middleware version.- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.login(value, so)¶
Verifies the PIN.
- Arguments:
value – The PIN value or a
SCWS.CredentialValue()
object. From6.23.1.0
middleware version, aSCWS.CredentialValue()
object can be created usingPin.requestCredential()
. May benull
orundefined
if a protected authentication path exists (seeToken.protectedAuthPath
). May also be set tofalse
, in which case the pin entering is delegated to the middleware through its own graphical interface, which is the recommended option: this guarantees that the pin does not go through to the browser.so – (optional) Boolean indicating if the verification operation must be made against the security officer (admnistrator or unblocking) PIN. If
false
orundefined
, targets the user PIN.
- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.change(oldCredential, newCredential)¶
Changes the PIN or more generally the credential defined by
newCredential
parameter. In the case of standard PIN, the operation can only be made against the user PIN. Using aSCWS.CredentialValue()
object fornewCredential
parameter is only available since6.23.1.0
middleware version.- Arguments:
oldCredential – The current PIN value. May be
null
orundefined
if a protected authentication path exists (seeToken.protectedAuthPath
).newCredential – The new PIN value or a credential value using
SCWS.CredentialValue()
. UsingPin.requestCredential()
to create aSCWS.CredentialValue()
is not supported. May benull
orundefined
if a protected authentication path exists.
- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.init(newValue)¶
Reinitializes the PIN value (unblocking it if required). The operation can only be made against the user PIN, and requires the security officer PIN to be verified (see
Pin.login()
).- Arguments:
newValue – The new PIN value. May be
null
orundefined
if a protected authentication path exists.
- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.logout()¶
Resets the verified status of the PIN (cancels a call to
Pin.login()
).- Returns:
A
Promise
resolved when the operation has been made (the resolution value is undefined).
- Pin.getConstraints()¶
Returns the format constraints of the PIN (which must be enforced when changing the PIN value).
The constraints are returned as an array of JavaScript objects, one for each constraint. The objects describing a constraint all have a
type
field, indicating the type of constraint, and optionally, some additional fields providing the parameters for the constraint. Thetype
can be one of the following (this list may be extended in the future):"minLength"
: The number of characters in the PIN must be at least the value given in theminLength
field."exactLength"
: The number of characters in the PIN must be exactly the value given in thelength
field."minMaxLength"
: The number of characters in the PIN must be between the value given in theminLength
field and the value given in themaxLength
field (inclusive)."numeric"
: The PIN must contain only numeric characters (0
to9
)."minDigits"
: The PIN must contain at leastcount
digits characters."minUpperCase"
: The PIN must contain at leastcount
uppercase letters."minSpecial"
: The PIN must contain at leastcount
special characters."minLowerCase"
: The PIN must contain at leastcount
lowercase letters."newOldDifferent"
: The new PIN value must be different from the old PIN value."newOldDissimilar"
: At leastthreshold
percent of the characters must differ between the new PIN and the old PIN value."maxIdenticalSequence"
: There must be no sequences ofcount
identical characters."maxIncDecSequence"
: There must be no sequences ofcount
increasing/decreasing characters”
- Returns:
A
Promise
resolving to the constraints description, as described above.
- Pin.checkConstraints(oldPin, newPin)¶
Checks the format constraints of the PIN.
The constraints (obtained using the
Pin.getConstraints()
method) are checked against the provided old and new PIN values. This method can be used to provide feedback to the user when changing their PIN value.The result of the check is returned as an array of boolean, each value indicating whether the constraint is fulfilled or not (in the same order as the array returned from
getConstraints
).- Arguments:
oldPin – The current PIN value (only used to check the
"newOldDifferent"
and"newOldDissimilar"
constraints).newPin – The new PIN value to be checked.
- Returns:
A
Promise
resolving to the result array.
- class SCWS.CredentialState()¶
Represents the credential state during a specific operation. See
Pin.requestCredential()
function.The constructor takes two parameters:
state
and a potentialerror
. Thestate
argument is a Javascript object with the following fields:pinTriesLeft
: the PIN remaining tries. Can be obtained withPin.remainingTries
.bioFingerprint
(optional) : fingerprint authentication object information as a Javascript object with the following fields:triesLeft
: the remaining tries of the fingerprint authentication object.fingers
: an Array of 10 Booleans, indicating if corresponding finger is enrolled or not. Position0
stands for left little finger, position9
stands for right little finger.
bioFacial
(optional) : facial authentication object information as a Javascript object with the following fields:triesLeft
: the remaining tries of the facial authentication object.
- Arguments:
state – the pin state as a Javascript object as defined above.
error – a potential error message as a string that can be displayed in the PIN dialog during a specific process.
- CredentialState.remainingTries¶
Number of remaining tries for the PIN verification to be displayed in the PIN Dialog. Can be set to
null
to not display this information.
- CredentialState.fingerprintRemainingTries¶
If applicable, number of remaining tries for the fingerprint authentication object to be displayed in the PIN Dialog. Can be set to
null
to not display this information.
- CredentialState.fingerprintFingers¶
If applicable, an Array containing 10 Booleans. Each Boolean indicates if corresponding finger is enrolled or not. Position 0 stands for left little finger, position 9 stands for right little finger.
- CredentialState.facialRemainingTries¶
If applicable, number of remaining tries for the facial authentication object to be displayed in the PIN Dialog. Can be set to
null
to not display this information.
- CredentialState.error¶
Potential error message that can be displayed in the PIN Dialog. Can be set to
null
to not display this information.
- class SCWS.CredentialValue()¶
Represents the credential value that can be used for token operations. It can be obtained by using
Pin.requestCredential()
or created using this constructor. The constructor takes one parameter:value
which is an object with the following fields:type
: the credential type as a string. Can be"pin"
,"finger"
or"facial"
.subtype
: for finger credential type, the subtype is the finger index as an integer. It must beundefined
otherwise.0
stands for left little finger,9
stands for right little finger.
data
: the credential value as anArrayBuffer
.
- CredentialValue.value¶
Credential value that can be provided to
Pin.login()
process. This can obtained by usingrequestCredential()
function.