Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Node.js Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Node.js) ScMinidriver - Get Smartcard Properties

See more ScMinidriver Examples

Gets information about the smart card currently inserted in the reader (or USB token).

Install Chilkat for Node.js and Electron using npm at

Chilkat npm packages for Node.js

Chilkat npm packages for Electron

on Windows, Linux, MacOSX, and ARM

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}

function chilkatExample() {

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var scmd = new chilkat.ScMinidriver();

    // Reader names (smart card readers or USB tokens) can be discovered
    // via PCSC List Readers or PCSC Find Smart Cards
    var readerName = "Alcor Micro USB Smart Card Reader 0";
    var success = scmd.AcquireContext(readerName);
    if (success == false) {
        console.log(scmd.LastErrorText);
        return;
    }

    var json = new chilkat.JsonObject();
    json.EmitCompact = false;

    success = scmd.GetCardProperties(json);
    if (success == false) {
        console.log(scmd.LastErrorText);
        return;
    }

    console.log(json.Emit());

    // Here is sample output:
    // See below for sample code to parse the JSON.
    // 
    // NOTE: Not all smart cards support all properties.
    // The GetCardProperties method will return information for all properties supported by the card.

    // {
    //   "bytesAvailable": 74752,
    //   "containersAvailable": 18,
    //   "maxKeyContainers": 20,
    //   "capabilities": {
    //     "fCertificateCompression": false,
    //     "fKeyGen": true
    //   },
    //   "keySizes": {
    //     "minimumBitlen": 2048,
    //     "defaultBitlen": 2048,
    //     "maximumBitlen": 4096,
    //     "incrementalBitlen": 1024
    //   },
    //   "readOnly": false,
    //   "cacheMode": "global",
    //   "supportsWinX509Enrollment": true,
    //   "guid": "1201803d-03e6-772a-3d80-0112e6032a77",
    //   "serial": "e6032a773d800112e6032a77",
    //   "pins": [
    //     "user",
    //     "admin",
    //     "role3",
    //     "role4"
    //   ],
    //   "pin": {
    //     "user": {
    //       "type": "regular",
    //       "purpose": "primaryCard",
    //       "changePermission": [
    //         "user"
    //       ],
    //       "unblockPermission": [
    //         "admin"
    //       ],
    //       "cachePolicy": "normal",
    //       "policyInfo": "00000000",
    //       "flags": "00000000",
    //       "acceptPlainTextPin": true,
    //       "generateSessionPin": false
    //     },
    //     "admin": {
    //       "type": "challenge/response",
    //       "purpose": "administrator",
    //       "changePermission": [
    //         "admin"
    //       ],
    //       "cachePolicy": "normal",
    //       "policyInfo": "00000000",
    //       "flags": "00000000"
    //     },
    //     "role3": {
    //       "type": "regular",
    //       "purpose": "digitalSignature",
    //       "changePermission": [
    //         "role3"
    //       ],
    //       "unblockPermission": [
    //         "role4"
    //       ],
    //       "cachePolicy": "alwaysPrompt",
    //       "policyInfo": "00000000",
    //       "flags": "00000000",
    //       "acceptPlainTextPin": true,
    //       "generateSessionPin": false
    //     },
    //     "role4": {
    //       "type": "regular",
    //       "purpose": "unblockOnly",
    //       "changePermission": [
    //         "role4"
    //       ],
    //       "cachePolicy": "normal",
    //       "policyInfo": "00000000",
    //       "flags": "00000000",
    //       "acceptPlainTextPin": true,
    //       "generateSessionPin": false
    //     }
    //   },
    //   "importSupport": [
    //     "plainText",
    //     "rsaKeyest",
    //     "eccKeyest",
    //     "symmetric"
    //   ],
    //   "algorithms": [
    //     "AES"
    //   ],
    //   "paddingSchemes": [
    //     "block",
    //     "pkcs1",
    //     "pss",
    //     "oaep"
    //   ],
    //   "chainingModes": [
    //     "ChainingModeCBC"
    //   ]
    // }

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    var strVal;

    var bytesAvailable = json.IntOf("bytesAvailable");
    var containersAvailable = json.IntOf("containersAvailable");
    var maxKeyContainers = json.IntOf("maxKeyContainers");
    var capabilitiesFCertificateCompression = json.BoolOf("capabilities.fCertificateCompression");
    var capabilitiesFKeyGen = json.BoolOf("capabilities.fKeyGen");
    var keySizesMinimumBitlen = json.IntOf("keySizes.minimumBitlen");
    var keySizesDefaultBitlen = json.IntOf("keySizes.defaultBitlen");
    var keySizesMaximumBitlen = json.IntOf("keySizes.maximumBitlen");
    var keySizesIncrementalBitlen = json.IntOf("keySizes.incrementalBitlen");
    var readOnly = json.BoolOf("readOnly");
    var cacheMode = json.StringOf("cacheMode");
    var supportsWinX509Enrollment = json.BoolOf("supportsWinX509Enrollment");
    var guid = json.StringOf("guid");
    var serial = json.StringOf("serial");
    var pinUserType = json.StringOf("pin.user.type");
    var pinUserPurpose = json.StringOf("pin.user.purpose");
    var pinUserCachePolicy = json.StringOf("pin.user.cachePolicy");
    var pinUserPolicyInfo = json.StringOf("pin.user.policyInfo");
    var pinUserFlags = json.StringOf("pin.user.flags");
    var pinUserAcceptPlainTextPin = json.BoolOf("pin.user.acceptPlainTextPin");
    var pinUserGenerateSessionPin = json.BoolOf("pin.user.generateSessionPin");
    var pinAdminType = json.StringOf("pin.admin.type");
    var pinAdminPurpose = json.StringOf("pin.admin.purpose");
    var pinAdminCachePolicy = json.StringOf("pin.admin.cachePolicy");
    var pinAdminPolicyInfo = json.StringOf("pin.admin.policyInfo");
    var pinAdminFlags = json.StringOf("pin.admin.flags");
    var pinRole3Type = json.StringOf("pin.role3.type");
    var pinRole3Purpose = json.StringOf("pin.role3.purpose");
    var pinRole3CachePolicy = json.StringOf("pin.role3.cachePolicy");
    var pinRole3PolicyInfo = json.StringOf("pin.role3.policyInfo");
    var pinRole3Flags = json.StringOf("pin.role3.flags");
    var pinRole3AcceptPlainTextPin = json.BoolOf("pin.role3.acceptPlainTextPin");
    var pinRole3GenerateSessionPin = json.BoolOf("pin.role3.generateSessionPin");
    var pinRole4Type = json.StringOf("pin.role4.type");
    var pinRole4Purpose = json.StringOf("pin.role4.purpose");
    var pinRole4CachePolicy = json.StringOf("pin.role4.cachePolicy");
    var pinRole4PolicyInfo = json.StringOf("pin.role4.policyInfo");
    var pinRole4Flags = json.StringOf("pin.role4.flags");
    var pinRole4AcceptPlainTextPin = json.BoolOf("pin.role4.acceptPlainTextPin");
    var pinRole4GenerateSessionPin = json.BoolOf("pin.role4.generateSessionPin");
    var i = 0;
    var count_i = json.SizeOfArray("pins");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pins[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.user.changePermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.user.changePermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.user.unblockPermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.user.unblockPermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.admin.changePermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.admin.changePermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.role3.changePermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.role3.changePermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.role3.unblockPermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.role3.unblockPermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("pin.role4.changePermission");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("pin.role4.changePermission[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("importSupport");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("importSupport[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("algorithms");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("algorithms[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("paddingSchemes");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("paddingSchemes[i]");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("chainingModes");
    while (i < count_i) {
        json.I = i;
        strVal = json.StringOf("chainingModes[i]");
        i = i+1;
    }

    // Delete the context when finished with the card.
    success = scmd.DeleteContext();
    if (success == false) {
        console.log(scmd.LastErrorText);
    }


}

chilkatExample();

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.