Skip to main content
Version: 6.28.2

API Reference

IdBoltSession

The main class of ID Bolt. It represents a session in which the end-user is guided through a workflow to scan their ID. The IdBoltSession.onCompletion() callback is called when the user has scanned their ID, the ID has been accepted and the ID Bolt pop-up is closed. Similarly, IdBoltSession.onCancellation() is called when the user closes the ID Bolt pop-up without finishing the full process successfully.

Using validators, ID Bolt can verify the expiration date or other features of the ID. Optionally, this can be done without sharing any personally identifiable information (PII) with your website.

Methods

create

SignatureDescription
static create(serviceUrl: string, options: IdBoltCreateSessionOptions): IdBoltSessionPrimary way to create an ID Bolt session.
Parameters
  • serviceUrl: string: URL that ID Bolt loads when started. Provided in your account on the Scandit dashboard.
note

The default value app.id-scanning.com is an alias that points to Scandit’s servers. In a production environment it can be changed to your own domain name pointing to Scandit’s servers. This will require you to configure a CNAME record in the DNS settings of your domain.

  • options: IdBoltCreateSessionOptions: Object specifying the session options:
    • licenseKey: string: Your license key, provided in you account on the Scandit dashboard.
    • documentSelection: DocumentSelection: Object specifying the acceptable documents. See DocumentSelection.
    • returnDataMode: ReturnDataMode: Defines the extent of the data returned by the onCompletion() callback. Use:
      • ReturnDataMode.FullWithImages to get all extracted data and images.
      • ReturnDataMode.Full to get all extracted data without images.
    • validation?: Validators[]: Optional array of validators, default: []. See Validators.
    • locale?: string: the language in which the text is displayed. Currently only english ("en") is supported. Default: "en".

Once created, a session object does nothing until you execute start() on it:

const idBoltSession = IdBoltSession.create(ID_BOLT_URL, {
licenseKey: LICENSE_KEY,
documentSelection,
returnDataMode: ReturnDataMode.FullWithImages,
validation: [Validators.notExpired()],
});
await idBoltSession.start();

onCompletion

SignatureDescription
IdBoltSession.onCompletion: (result: CompletionResult) => voidA callback that is called when the user has successfully scanned their ID. result.capturedId will contain the document data.

onCancellation

SignatureDescription
IdBoltSession.onCancellation: (reason: CancellationReason) => voidA callback that is called when the user has closed the ID Bolt pop-up without having finished the scanning workflow. The reasona argument contains the reason for the cancellation.

start

SignatureDescription
async IdBoltSession.start(): Promise<string>Open the ID Bolt pop-up to start the scanning workflow. This method returns a session ID identifying the session.

DocumentSelection

A class to define which types of documents the ID Bolt will accept. The list of documents is provided as specific document objects, instantiated with a Region. For example passports from the USA would be new Passport(Region.USA).

Documents that are not acceptable may still get recognized by the scanner. In this case the user will be notified to use one of the accepted document types.

Methods

create

SignatureDescription
static DocumentSelection.create(selection: Selection): DocumentSelectionPrimary way to create a DocumentSelection instance with all the included and excluded documents. Only Selection.include is mandatory.
const documentSelection = DocumentSelection.create({
accepted: [
new Passport(Region.Any),
// You can either use country name or ISO code
new IDCard(Region.FRA),
new DriverLicense(Region.France)
],
rejected: [
// You can explicitly reject certain documents, if they would be included otherwise.
new Passport(Region.Switzerland)
],
});

If you have very specific rules, you can use the Selection.customCallback option where you can decide if the scanned document should be accepted or not:

const documentSelection = DocumentSelection.create({
include: [new Passport(Region.USA)],
customCallback: (capturedId: CapturedId, preCheckResults: PreCheckResults) => {
if (capturedId.documentNumber === "123") {
return {
valid: false,
// this message will be displayed to the user
message: `Documents starting with "123" are not accepted.`,
};
}
// when not returning anything, the default behavior will take place
},
});

Document Types

Each document type is represented with a specific class. These classes are instantiated in with a specific region to select accepted and rejected documents.

Passport

Includes all Passports

new Passport(Region.USA) // US passports
new Passport(Region.Any) // Any passport

IDCard

Includes national identity cards

new IDCard(Region.Germany) // German identity cards
new IDCard(Region.Any) // National identity card from any country

DriverLicense

Includes driver licenses

new DriverLicense(Region.France) // French driver license
new DriverLicense(Region.Any) // Driver license card from any country

Validators

Validators enable you to run checks on the scanned ID. They are only run on accepted documents.

Methods

notExpired

SignatureDescription
Validators.notExpired()Checks that the document has not expired. Note that this test will not pass if the expiration date could not be determined from the extracted data.

notExpiredIn

SignatureDescription
Validators.notExpiredIn(duration: Duration)Checks that the document has still not expired after the duration passed in argument. This test will not pass if the expiration date could not be determined from the extracted data.
Duration is an object with following properties: days?: number, months?: number.

In the following example, the ID must not expire in the next 12 months:

const idBoltSession = IdBoltSession.create(ID_BOLT_URL, {
licenseKey: LICENSE_KEY,
documentSelection: ...,
returnDataMode: RETURN_DATA_MODE.FULL_WITH_IMAGES,
validation: [Validators.notExpiredIn({months: 12})],
});

US.isRealID

SignatureDescription
Validators.US.isRealID()Checks that the scanned driver license is compliant with the rules of Real ID defined by the American Association of Motor Vehicle Administrators (AAMVA). Note that this test will not pass if the scanned document is not an AAMVA document.

Interfaces

CapturedId

The interface defining the object you receive in CompletionResult.capturedId.

Properties

PropertyTypeDefaultDescription
firstNamestringnull
lastNamestringnull
fullNamestring
sexstringnull
nationalitystringnull
addressstringnull
issuingCountryRegionnullThe ISO (Alpha-3 code) abbreviation of the issuing country of the document.
documentNumberstringnull
documentAdditionalNumberstringnull
dateOfBirthDateResultnull
agenumbernull
dateOfExpiryDateResultnull
isExpiredbooleannull
dateOfIssueDateResultnull
documentTypeDocumentTypeOne of "Passport" | "IDCard" | "DriverLicense"
capturedResultTypesstring[]
imagesImageDatanullObject containing base64 encoded jpg images

ImageData

Properties

PropertyTypeDefaultDescription
fullFramestring[]nullRaw captured frame used for detection. Array of base64 encoded jpg images
croppedstring[]nullCropped face and ID images, if available. Array of base64 encoded jpg images

DateResult

An object representing a date.

Properties

PropertyType
daynumber
monthnumber
yearnumber

PreCheckResults

An object containing the current acceptance status for the scanned document according to the configured rules in IdBoltSession.documentSelection.

Properties

PropertyTypeDescription
isIncludedbooleanThe scanned document is acceptable.
isExcludedbooleanThe scanned document is excluded.
validbooleanFinal outcome, the document is considered acceptable.

Const

Region

An enumeration of regions (countries), both as ISO codes as well as names.

Example:

// France
Region.FRA;
Region.France;

Region.FRA === Region.France === "FRA"; // true

// Any
Region.Any;

ReturnDataMode

Values used by IdBoltCreateSessionOptions to define what data is returned by IdBoltSession.onCompletion(). Possible values are:

ValueDescription
FullAll extracted data is returned, but images are excluded.
FullWithImagesAll extracted data is returned, including images of the scanned ID.