graphene-pk11
Advanced tools
Comparing version 2.0.34 to 2.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./core/object"), exports); | ||
@@ -14,4 +14,4 @@ tslib_1.__exportStar(require("./core/error"), exports); | ||
function getPKCS11ErrorCode(error) { | ||
var regex = /^\w+:(\d+)/i; | ||
var res = regex.exec(error.message); | ||
const regex = /^\w+:(\d+)/i; | ||
const res = regex.exec(error.message); | ||
if (res) { | ||
@@ -18,0 +18,0 @@ return parseInt(res[1], 10); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var object = require("./object"); | ||
var Collection = (function (_super) { | ||
tslib_1.__extends(Collection, _super); | ||
function Collection(items, lib, classType) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.items_ = items; | ||
_this.lib = lib; | ||
_this.classType = classType; | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const object = tslib_1.__importStar(require("./object")); | ||
class Collection extends object.BaseObject { | ||
constructor(items, lib, classType) { | ||
super(lib); | ||
this.items_ = items; | ||
this.lib = lib; | ||
this.classType = classType; | ||
} | ||
Object.defineProperty(Collection.prototype, "length", { | ||
get: function () { | ||
return this.items_.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Collection.prototype.items = function (index) { | ||
var handle = this.items_[index]; | ||
get length() { | ||
return this.items_.length; | ||
} | ||
items(index) { | ||
const handle = this.items_[index]; | ||
return new this.classType(handle, this.lib); | ||
}; | ||
Collection.prototype.indexOf = function (obj, fromIndex) { | ||
if (fromIndex === void 0) { fromIndex = 0; } | ||
} | ||
indexOf(obj, fromIndex = 0) { | ||
if (obj.lib.libPath === obj.lib.libPath) { | ||
for (var i = fromIndex; i < this.items_.length; i++) { | ||
var item = this.items(i); | ||
for (let i = fromIndex; i < this.items_.length; i++) { | ||
const item = this.items(i); | ||
if (item.handle.equals(obj.handle)) { | ||
@@ -36,5 +29,4 @@ return i; | ||
return -1; | ||
}; | ||
return Collection; | ||
}(object.BaseObject)); | ||
} | ||
} | ||
exports.Collection = Collection; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var Pkcs11Error = (function (_super) { | ||
tslib_1.__extends(Pkcs11Error, _super); | ||
function Pkcs11Error(code, func) { | ||
var _this = _super.call(this) || this; | ||
_this.message = "Pkcs11Error: Error in " + func + " function " + Pkcs11Result[code] + "(" + code + ")"; | ||
_this.code = code; | ||
_this.func = func; | ||
_this.stack = (new Error(_this.message)).stack; | ||
return _this; | ||
class Pkcs11Error extends Error { | ||
constructor(code, func) { | ||
super(); | ||
this.message = `Pkcs11Error: Error in ${func} function ${Pkcs11Result[code]}(${code})`; | ||
this.code = code; | ||
this.func = func; | ||
this.stack = (new Error(this.message)).stack; | ||
} | ||
return Pkcs11Error; | ||
}(Error)); | ||
} | ||
exports.Pkcs11Error = Pkcs11Error; | ||
@@ -17,0 +13,0 @@ var Pkcs11Result; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var BaseObject = (function () { | ||
function BaseObject(lib) { | ||
class BaseObject { | ||
constructor(lib) { | ||
Object.defineProperty(this, "lib", { | ||
writable: true, | ||
enumerable: false | ||
enumerable: false, | ||
}); | ||
this.lib = lib; | ||
} | ||
return BaseObject; | ||
}()); | ||
} | ||
exports.BaseObject = BaseObject; | ||
var HandleObject = (function (_super) { | ||
tslib_1.__extends(HandleObject, _super); | ||
function HandleObject(handle, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.handle = handle; | ||
return _this; | ||
class HandleObject extends BaseObject { | ||
constructor(handle, lib) { | ||
super(lib); | ||
this.handle = handle; | ||
} | ||
HandleObject.prototype.getInfo = function () { }; | ||
; | ||
return HandleObject; | ||
}(BaseObject)); | ||
getInfo() { | ||
} | ||
} | ||
exports.HandleObject = HandleObject; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function dateFromString(text) { | ||
var reg = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/; | ||
var vals = reg.exec(text); | ||
if (!vals) | ||
const reg = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/; | ||
const values = reg.exec(text); | ||
if (!values) { | ||
return null; | ||
return new Date(vals[1] + "-" + vals[2] + "-" + vals[3] + " " + vals[4] + ":" + vals[5] + ":" + vals[6] + ":" + vals[7]); | ||
} | ||
return new Date(`${values[1]}-${values[2]}-${values[3]} ${values[4]}:${values[5]}:${values[6]}:${values[7]}`); | ||
} | ||
exports.dateFromString = dateFromString; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("../core"); | ||
var mech_1 = require("../mech"); | ||
var Cipher = (function (_super) { | ||
tslib_1.__extends(Cipher, _super); | ||
function Cipher(session, alg, key, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.session = session; | ||
_this.init(alg, key); | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("../core")); | ||
const mech_1 = require("../mech"); | ||
class Cipher extends core.BaseObject { | ||
constructor(session, alg, key, lib) { | ||
super(lib); | ||
this.session = session; | ||
this.init(alg, key); | ||
} | ||
Cipher.prototype.init = function (alg, key) { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_EncryptInit(this.session.handle, pMech, key.handle); | ||
}; | ||
Cipher.prototype.update = function (data) { | ||
update(data) { | ||
try { | ||
data = new Buffer(data); | ||
var enc = new Buffer(data.length + 1024); | ||
var res = this.lib.C_EncryptUpdate(this.session.handle, data, enc); | ||
data = Buffer.from(data); | ||
const enc = Buffer.alloc(data.length + 1024); | ||
const res = this.lib.C_EncryptUpdate(this.session.handle, data, enc); | ||
return res; | ||
@@ -29,22 +23,27 @@ } | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
} | ||
throw e; | ||
} | ||
}; | ||
Cipher.prototype.final = function () { | ||
var BUF_SIZE = 4048; | ||
var enc = new Buffer(BUF_SIZE); | ||
var res = this.lib.C_EncryptFinal(this.session.handle, enc); | ||
} | ||
final() { | ||
const BUF_SIZE = 4048; | ||
const enc = Buffer.alloc(BUF_SIZE); | ||
const res = this.lib.C_EncryptFinal(this.session.handle, enc); | ||
return res; | ||
}; | ||
Cipher.prototype.once = function (data, enc, cb) { | ||
var _data = new Buffer(data); | ||
} | ||
once(data, enc, cb) { | ||
const bytes = Buffer.from(data); | ||
if (cb) { | ||
this.lib.C_Encrypt(this.session.handle, _data, enc, cb); | ||
this.lib.C_Encrypt(this.session.handle, bytes, enc, cb); | ||
} | ||
else | ||
return this.lib.C_Encrypt(this.session.handle, _data, enc); | ||
}; | ||
return Cipher; | ||
}(core.BaseObject)); | ||
else { | ||
return this.lib.C_Encrypt(this.session.handle, bytes, enc); | ||
} | ||
} | ||
init(alg, key) { | ||
const pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_EncryptInit(this.session.handle, pMech, key.handle); | ||
} | ||
} | ||
exports.Cipher = Cipher; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("../core"); | ||
var mech_1 = require("../mech"); | ||
var DEFAULT_BLOCK_SIZE = 256 >> 3; | ||
var Decipher = (function (_super) { | ||
tslib_1.__extends(Decipher, _super); | ||
function Decipher(session, alg, key, blockSize, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.blockSize = DEFAULT_BLOCK_SIZE; | ||
_this.session = session; | ||
_this.blockSize = blockSize || DEFAULT_BLOCK_SIZE; | ||
_this.init(alg, key); | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("../core")); | ||
const mech_1 = require("../mech"); | ||
const DEFAULT_BLOCK_SIZE = 256 >> 3; | ||
class Decipher extends core.BaseObject { | ||
constructor(session, alg, key, blockSize, lib) { | ||
super(lib); | ||
this.blockSize = DEFAULT_BLOCK_SIZE; | ||
this.session = session; | ||
this.blockSize = blockSize || DEFAULT_BLOCK_SIZE; | ||
this.init(alg, key); | ||
} | ||
Decipher.prototype.init = function (alg, key) { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_DecryptInit(this.session.handle, pMech, key.handle); | ||
}; | ||
Decipher.prototype.update = function (data) { | ||
update(data) { | ||
try { | ||
var len = Math.ceil(data.length / this.blockSize) * this.blockSize; | ||
var dec = new Buffer(len); | ||
var res = this.lib.C_DecryptUpdate(this.session.handle, data, dec); | ||
const len = Math.ceil(data.length / this.blockSize) * this.blockSize; | ||
const dec = Buffer.alloc(len); | ||
const res = this.lib.C_DecryptUpdate(this.session.handle, data, dec); | ||
return res; | ||
@@ -32,20 +26,25 @@ } | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
} | ||
throw e; | ||
} | ||
}; | ||
Decipher.prototype.final = function () { | ||
var dec = new Buffer(this.blockSize); | ||
var res = this.lib.C_DecryptFinal(this.session.handle, dec); | ||
} | ||
final() { | ||
const dec = Buffer.alloc(this.blockSize); | ||
const res = this.lib.C_DecryptFinal(this.session.handle, dec); | ||
return res; | ||
}; | ||
Decipher.prototype.once = function (data, dec, cb) { | ||
} | ||
once(data, dec, cb) { | ||
if (cb) { | ||
this.lib.C_Decrypt(this.session.handle, data, dec, cb); | ||
} | ||
else | ||
else { | ||
return this.lib.C_Decrypt(this.session.handle, data, dec); | ||
}; | ||
return Decipher; | ||
}(core.BaseObject)); | ||
} | ||
} | ||
init(alg, key) { | ||
const pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_DecryptInit(this.session.handle, pMech, key.handle); | ||
} | ||
} | ||
exports.Decipher = Decipher; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("../core"); | ||
var mech = require("../mech"); | ||
var Digest = (function (_super) { | ||
tslib_1.__extends(Digest, _super); | ||
function Digest(session, alg, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.session = session; | ||
_this.init(alg); | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("../core")); | ||
const mech = tslib_1.__importStar(require("../mech")); | ||
class Digest extends core.BaseObject { | ||
constructor(session, alg, lib) { | ||
super(lib); | ||
this.session = session; | ||
this.init(alg); | ||
} | ||
Digest.prototype.init = function (alg) { | ||
var pMech = mech.Mechanism.create(alg); | ||
this.lib.C_DigestInit(this.session.handle, pMech); | ||
}; | ||
Digest.prototype.update = function (data) { | ||
update(data) { | ||
try { | ||
var _data = new Buffer(data); | ||
this.lib.C_DigestUpdate(this.session.handle, _data); | ||
const bytes = Buffer.from(data); | ||
this.lib.C_DigestUpdate(this.session.handle, bytes); | ||
} | ||
@@ -27,22 +21,27 @@ catch (e) { | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
} | ||
throw e; | ||
} | ||
}; | ||
Digest.prototype.final = function () { | ||
var digest = new Buffer(1024); | ||
var res = this.lib.C_DigestFinal(this.session.handle, digest); | ||
} | ||
final() { | ||
const digest = Buffer.alloc(1024); | ||
const res = this.lib.C_DigestFinal(this.session.handle, digest); | ||
return res; | ||
}; | ||
Digest.prototype.once = function (data, cb) { | ||
var digest = new Buffer(1024); | ||
var _data = new Buffer(data); | ||
} | ||
once(data, cb) { | ||
const digest = Buffer.alloc(1024); | ||
const bytes = Buffer.from(data); | ||
if (cb) { | ||
this.lib.C_Digest(this.session.handle, _data, digest, cb); | ||
this.lib.C_Digest(this.session.handle, bytes, digest, cb); | ||
} | ||
else | ||
return this.lib.C_Digest(this.session.handle, _data, digest); | ||
}; | ||
return Digest; | ||
}(core.BaseObject)); | ||
else { | ||
return this.lib.C_Digest(this.session.handle, bytes, digest); | ||
} | ||
} | ||
init(alg) { | ||
const pMech = mech.Mechanism.create(alg); | ||
this.lib.C_DigestInit(this.session.handle, pMech); | ||
} | ||
} | ||
exports.Digest = Digest; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("../core"); | ||
var mech = require("../mech"); | ||
var Sign = (function (_super) { | ||
tslib_1.__extends(Sign, _super); | ||
function Sign(session, alg, key, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.session = session; | ||
_this.init(alg, key); | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("../core")); | ||
const mech = tslib_1.__importStar(require("../mech")); | ||
class Sign extends core.BaseObject { | ||
constructor(session, alg, key, lib) { | ||
super(lib); | ||
this.session = session; | ||
this.init(alg, key); | ||
} | ||
Sign.prototype.init = function (alg, key) { | ||
var pMech = mech.Mechanism.create(alg); | ||
this.lib.C_SignInit(this.session.handle, pMech, key.handle); | ||
}; | ||
Sign.prototype.update = function (data) { | ||
update(data) { | ||
try { | ||
var _data = new Buffer(data); | ||
this.lib.C_SignUpdate(this.session.handle, _data); | ||
const bytes = Buffer.from(data); | ||
this.lib.C_SignUpdate(this.session.handle, bytes); | ||
} | ||
@@ -27,22 +21,27 @@ catch (e) { | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
} | ||
throw e; | ||
} | ||
}; | ||
Sign.prototype.final = function () { | ||
var sig = new Buffer(1024); | ||
var res = this.lib.C_SignFinal(this.session.handle, sig); | ||
} | ||
final() { | ||
const sig = Buffer.alloc(1024); | ||
const res = this.lib.C_SignFinal(this.session.handle, sig); | ||
return res; | ||
}; | ||
Sign.prototype.once = function (data, cb) { | ||
var signature = new Buffer(1024); | ||
var _data = new Buffer(data); | ||
} | ||
once(data, cb) { | ||
const signature = Buffer.alloc(1024); | ||
const bytes = Buffer.from(data); | ||
if (cb) { | ||
this.lib.C_Sign(this.session.handle, _data, signature, cb); | ||
this.lib.C_Sign(this.session.handle, bytes, signature, cb); | ||
} | ||
else | ||
return this.lib.C_Sign(this.session.handle, _data, signature); | ||
}; | ||
return Sign; | ||
}(core.BaseObject)); | ||
else { | ||
return this.lib.C_Sign(this.session.handle, bytes, signature); | ||
} | ||
} | ||
init(alg, key) { | ||
const pMech = mech.Mechanism.create(alg); | ||
this.lib.C_SignInit(this.session.handle, pMech, key.handle); | ||
} | ||
} | ||
exports.Sign = Sign; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("../core"); | ||
var mech_1 = require("../mech"); | ||
var INVALID = 192; | ||
var Verify = (function (_super) { | ||
tslib_1.__extends(Verify, _super); | ||
function Verify(session, alg, key, lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.session = session; | ||
_this.init(alg, key); | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("../core")); | ||
const mech_1 = require("../mech"); | ||
const INVALID = 192; | ||
class Verify extends core.BaseObject { | ||
constructor(session, alg, key, lib) { | ||
super(lib); | ||
this.session = session; | ||
this.init(alg, key); | ||
} | ||
Verify.prototype.init = function (alg, key) { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_VerifyInit(this.session.handle, pMech, key.handle); | ||
}; | ||
Verify.prototype.update = function (data) { | ||
update(data) { | ||
try { | ||
var _data = new Buffer(data); | ||
this.lib.C_VerifyUpdate(this.session.handle, _data); | ||
const bytes = Buffer.from(data); | ||
this.lib.C_VerifyUpdate(this.session.handle, bytes); | ||
} | ||
catch (e) { | ||
try { | ||
this.final(new Buffer(0)); | ||
this.final(Buffer.alloc(0)); | ||
} | ||
catch (e) { } | ||
catch (e) { | ||
} | ||
throw e; | ||
} | ||
}; | ||
Verify.prototype.final = function (signature) { | ||
var res = false; | ||
} | ||
final(signature) { | ||
let res = false; | ||
try { | ||
@@ -43,7 +38,7 @@ res = this.lib.C_VerifyFinal(this.session.handle, signature); | ||
return res; | ||
}; | ||
Verify.prototype.once = function (data, signature, cb) { | ||
var _data = new Buffer(data); | ||
} | ||
once(data, signature, cb) { | ||
const bytes = Buffer.from(data); | ||
if (cb) { | ||
this.lib.C_Verify(this.session.handle, _data, signature, function (err, data) { | ||
this.lib.C_Verify(this.session.handle, bytes, signature, (err, data2) => { | ||
if (err && core.getPKCS11ErrorCode(err) === INVALID) { | ||
@@ -53,3 +48,3 @@ cb(null, false); | ||
else { | ||
cb(err, data); | ||
cb(err, data2); | ||
} | ||
@@ -59,5 +54,5 @@ }); | ||
else { | ||
var res = false; | ||
let res = false; | ||
try { | ||
res = this.lib.C_Verify(this.session.handle, _data, signature); | ||
res = this.lib.C_Verify(this.session.handle, bytes, signature); | ||
} | ||
@@ -71,5 +66,8 @@ catch (err) { | ||
} | ||
}; | ||
return Verify; | ||
}(core.BaseObject)); | ||
} | ||
init(alg, key) { | ||
const pMech = mech_1.Mechanism.create(alg); | ||
this.lib.C_VerifyInit(this.session.handle, pMech, key.handle); | ||
} | ||
} | ||
exports.Verify = Verify; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var params_1 = require("../params"); | ||
var AesCbcParams = (function () { | ||
function AesCbcParams(iv, data) { | ||
if (data === void 0) { data = new Buffer(0); } | ||
const params_1 = require("../params"); | ||
class AesCbcParams { | ||
constructor(iv, data = Buffer.alloc(0)) { | ||
this.type = params_1.MechParams.AesCBC; | ||
@@ -11,7 +10,21 @@ this.iv = iv; | ||
} | ||
AesCbcParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return this.iv; | ||
}; | ||
return AesCbcParams; | ||
}()); | ||
} | ||
} | ||
exports.AesCbcParams = AesCbcParams; | ||
class AesCbcEncryptDataParams { | ||
constructor(iv, data = Buffer.alloc(0)) { | ||
this.type = params_1.MechParams.AesCBC; | ||
this.iv = iv; | ||
this.data = data; | ||
} | ||
toCKI() { | ||
return { | ||
type: this.type, | ||
iv: this.iv, | ||
data: this.data, | ||
}; | ||
} | ||
} | ||
exports.AesCbcEncryptDataParams = AesCbcEncryptDataParams; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var params_1 = require("../params"); | ||
var AesCcmParams = (function () { | ||
function AesCcmParams(dataLength, nonce, aad, macLength) { | ||
if (aad === void 0) { aad = new Buffer(0); } | ||
if (macLength === void 0) { macLength = 0; } | ||
const params_1 = require("../params"); | ||
class AesCcmParams { | ||
constructor(dataLength, nonce, aad = Buffer.alloc(0), macLength = 0) { | ||
this.type = params_1.MechParams.AesCCM; | ||
@@ -14,3 +12,3 @@ this.dataLength = dataLength; | ||
} | ||
AesCcmParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return { | ||
@@ -21,7 +19,6 @@ aad: this.aad, | ||
nonce: this.nonce, | ||
type: this.type | ||
type: this.type, | ||
}; | ||
}; | ||
return AesCcmParams; | ||
}()); | ||
} | ||
} | ||
exports.AesCcmParams = AesCcmParams; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var params_1 = require("../params"); | ||
var AesGcmParams = (function () { | ||
function AesGcmParams(iv, aad, tagBits) { | ||
if (aad === void 0) { aad = new Buffer(0); } | ||
if (tagBits === void 0) { tagBits = 128; } | ||
const params_1 = require("../params"); | ||
class AesGcmParams { | ||
constructor(iv, aad = Buffer.alloc(0), tagBits = 128) { | ||
this.type = params_1.MechParams.AesGCM; | ||
@@ -14,3 +11,3 @@ this.iv = iv; | ||
} | ||
AesGcmParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return { | ||
@@ -21,17 +18,13 @@ iv: this.iv, | ||
tagBits: this.tagBits, | ||
type: this.type | ||
type: this.type, | ||
}; | ||
}; | ||
return AesGcmParams; | ||
}()); | ||
} | ||
} | ||
exports.AesGcmParams = AesGcmParams; | ||
var AesGcm240Params = (function (_super) { | ||
tslib_1.__extends(AesGcm240Params, _super); | ||
function AesGcm240Params() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.type = params_1.MechParams.AesGCMv240; | ||
return _this; | ||
class AesGcm240Params extends AesGcmParams { | ||
constructor() { | ||
super(...arguments); | ||
this.type = params_1.MechParams.AesGCMv240; | ||
} | ||
return AesGcm240Params; | ||
}(AesGcmParams)); | ||
} | ||
exports.AesGcm240Params = AesGcm240Params; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("../core"), exports); | ||
@@ -5,0 +5,0 @@ tslib_1.__exportStar(require("../object"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var namedCurves = [ | ||
{ name: "secp160r1", oid: "1.3.132.0.8", value: new Buffer("06052b81040008", "hex"), size: 160 }, | ||
{ name: "secp192r1", oid: "1.2.840.10045.3.1.1", value: new Buffer("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "secp256r1", oid: "1.2.840.10045.3.1.7", value: new Buffer("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "secp384r1", oid: "1.3.132.0.34", value: new Buffer("06052B81040022", "hex"), size: 384 }, | ||
{ name: "secp521r1", oid: "1.3.132.0.35", value: new Buffer("06052B81040023", "hex"), size: 521 }, | ||
{ name: "prime192r1", oid: "1.2.840.10045.3.1.1", value: new Buffer("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "prime256v1", oid: "1.2.840.10045.3.1.7", value: new Buffer("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "prime384v1", oid: "1.3.132.0.34", value: new Buffer("06052B81040022", "hex"), size: 384 }, | ||
{ name: "ansiX9p192r1", oid: "1.2.840.10045.3.1.1", value: new Buffer("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "ansiX9p256r1", oid: "1.2.840.10045.3.1.7", value: new Buffer("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "ansiX9p384r1", oid: "1.3.132.0.34", value: new Buffer("06052B81040022", "hex"), size: 384 }, | ||
{ name: "brainpoolP192r1", oid: "1.3.36.3.3.2.8.1.1.3", value: new Buffer("06092B2403030208010103", "hex"), size: 192 }, | ||
{ name: "brainpoolP224r1", oid: "1.3.36.3.3.2.8.1.1.5", value: new Buffer("06092B2403030208010105", "hex"), size: 224 }, | ||
{ name: "brainpoolP256r1", oid: "1.3.36.3.3.2.8.1.1.7", value: new Buffer("06092B2403030208010107", "hex"), size: 256 }, | ||
{ name: "curve25519", oid: "1.3.6.1.4.1.11591.15.1", value: new Buffer("06092B06010401DA470F01", "hex"), size: 256 }, | ||
const namedCurves = [ | ||
{ name: "secp160r1", oid: "1.3.132.0.8", value: Buffer.from("06052b81040008", "hex"), size: 160 }, | ||
{ name: "secp192r1", oid: "1.2.840.10045.3.1.1", value: Buffer.from("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "secp256r1", oid: "1.2.840.10045.3.1.7", value: Buffer.from("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "secp384r1", oid: "1.3.132.0.34", value: Buffer.from("06052B81040022", "hex"), size: 384 }, | ||
{ name: "secp521r1", oid: "1.3.132.0.35", value: Buffer.from("06052B81040023", "hex"), size: 521 }, | ||
{ name: "prime192r1", oid: "1.2.840.10045.3.1.1", value: Buffer.from("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "prime256v1", oid: "1.2.840.10045.3.1.7", value: Buffer.from("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "prime384v1", oid: "1.3.132.0.34", value: Buffer.from("06052B81040022", "hex"), size: 384 }, | ||
{ name: "ansiX9p192r1", oid: "1.2.840.10045.3.1.1", value: Buffer.from("06082A8648CE3D030101", "hex"), size: 192 }, | ||
{ name: "ansiX9p256r1", oid: "1.2.840.10045.3.1.7", value: Buffer.from("06082A8648CE3D030107", "hex"), size: 256 }, | ||
{ name: "ansiX9p384r1", oid: "1.3.132.0.34", value: Buffer.from("06052B81040022", "hex"), size: 384 }, | ||
{ name: "brainpoolP192r1", oid: "1.3.36.3.3.2.8.1.1.3", value: Buffer.from("06092B2403030208010103", "hex"), size: 192 }, | ||
{ name: "brainpoolP224r1", oid: "1.3.36.3.3.2.8.1.1.5", value: Buffer.from("06092B2403030208010105", "hex"), size: 224 }, | ||
{ name: "brainpoolP256r1", oid: "1.3.36.3.3.2.8.1.1.7", value: Buffer.from("06092B2403030208010107", "hex"), size: 256 }, | ||
{ name: "curve25519", oid: "1.3.6.1.4.1.11591.15.1", value: Buffer.from("06092B06010401DA470F01", "hex"), size: 256 }, | ||
]; | ||
var NamedCurve = (function () { | ||
function NamedCurve() { | ||
} | ||
NamedCurve.getByName = function (name) { | ||
for (var i in namedCurves) { | ||
var nc = namedCurves[i]; | ||
if (nc.name === name) | ||
class NamedCurve { | ||
static getByName(name) { | ||
for (const i in namedCurves) { | ||
const nc = namedCurves[i]; | ||
if (nc.name === name) { | ||
return nc; | ||
} | ||
} | ||
throw new Error("Can not find named curve by name '" + name + "'"); | ||
}; | ||
NamedCurve.getByOid = function (oid) { | ||
for (var i in namedCurves) { | ||
var nc = namedCurves[i]; | ||
if (nc.oid === oid) | ||
throw new Error(`Can not find named curve by name '${name}'`); | ||
} | ||
static getByOid(oid) { | ||
for (const i in namedCurves) { | ||
const nc = namedCurves[i]; | ||
if (nc.oid === oid) { | ||
return nc; | ||
} | ||
} | ||
throw new Error("Can not find named curve by oid '" + oid + "'"); | ||
}; | ||
NamedCurve.getByBuffer = function (buf) { | ||
for (var i in namedCurves) { | ||
var nc = namedCurves[i]; | ||
if (nc.value.equals(buf)) | ||
throw new Error(`Can not find named curve by oid '${oid}'`); | ||
} | ||
static getByBuffer(buf) { | ||
for (const i in namedCurves) { | ||
const nc = namedCurves[i]; | ||
if (nc.value.equals(buf)) { | ||
return nc; | ||
} | ||
} | ||
throw new Error("Can not find named curve by buffer value '" + buf.toString("hex") + "'"); | ||
}; | ||
return NamedCurve; | ||
}()); | ||
throw new Error(`Can not find named curve by buffer value '${buf.toString("hex")}'`); | ||
} | ||
} | ||
exports.NamedCurve = NamedCurve; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var params_1 = require("../params"); | ||
var EcdhParams = (function () { | ||
function EcdhParams(kdf, sharedData, publicData) { | ||
if (sharedData === void 0) { sharedData = new Buffer(0); } | ||
if (publicData === void 0) { publicData = new Buffer(0); } | ||
const params_1 = require("../params"); | ||
class EcdhParams { | ||
constructor(kdf, sharedData = null, publicData = null) { | ||
this.type = params_1.MechParams.EcDH; | ||
this.kdf = kdf; | ||
this.sharedData = sharedData; | ||
this.publicData = publicData; | ||
if (sharedData) { | ||
this.sharedData = sharedData; | ||
} | ||
if (publicData) { | ||
this.publicData = publicData; | ||
} | ||
} | ||
EcdhParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return this; | ||
}; | ||
return EcdhParams; | ||
}()); | ||
} | ||
} | ||
exports.EcdhParams = EcdhParams; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pkcs11 = require("pkcs11js"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
var EcKdf; | ||
@@ -5,0 +6,0 @@ (function (EcKdf) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pkcs11 = require("pkcs11js"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
var RsaMgf; | ||
@@ -5,0 +6,0 @@ (function (RsaMgf) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mech_1 = require("../../mech"); | ||
var mgf_1 = require("./mgf"); | ||
var params_1 = require("../params"); | ||
var RsaOaepParams = (function () { | ||
function RsaOaepParams(hashAlg, mgf, sourceData) { | ||
if (hashAlg === void 0) { hashAlg = mech_1.MechanismEnum.SHA1; } | ||
if (mgf === void 0) { mgf = mgf_1.RsaMgf.MGF1_SHA1; } | ||
if (sourceData === void 0) { sourceData = null; } | ||
const mech_1 = require("../../mech"); | ||
const params_1 = require("../params"); | ||
const mgf_1 = require("./mgf"); | ||
class RsaOaepParams { | ||
constructor(hashAlg = mech_1.MechanismEnum.SHA1, mgf = mgf_1.RsaMgf.MGF1_SHA1, sourceData = null) { | ||
this.source = 1; | ||
@@ -17,3 +14,3 @@ this.type = params_1.MechParams.RsaOAEP; | ||
} | ||
RsaOaepParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return { | ||
@@ -24,7 +21,6 @@ hashAlg: this.hashAlgorithm, | ||
sourceData: this.sourceData, | ||
type: this.type | ||
type: this.type, | ||
}; | ||
}; | ||
return RsaOaepParams; | ||
}()); | ||
} | ||
} | ||
exports.RsaOaepParams = RsaOaepParams; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mech_1 = require("../../mech"); | ||
var params_1 = require("../params"); | ||
var mgf_1 = require("./mgf"); | ||
var RsaPssParams = (function () { | ||
function RsaPssParams(hashAlg, mgf, saltLen) { | ||
if (hashAlg === void 0) { hashAlg = mech_1.MechanismEnum.SHA1; } | ||
if (mgf === void 0) { mgf = mgf_1.RsaMgf.MGF1_SHA1; } | ||
if (saltLen === void 0) { saltLen = 20; } | ||
const mech_1 = require("../../mech"); | ||
const params_1 = require("../params"); | ||
const mgf_1 = require("./mgf"); | ||
class RsaPssParams { | ||
constructor(hashAlg = mech_1.MechanismEnum.SHA1, mgf = mgf_1.RsaMgf.MGF1_SHA1, saltLen = 20) { | ||
this.type = params_1.MechParams.RsaPSS; | ||
@@ -16,3 +13,3 @@ this.hashAlgorithm = hashAlg; | ||
} | ||
RsaPssParams.prototype.toCKI = function () { | ||
toCKI() { | ||
return { | ||
@@ -22,7 +19,6 @@ hashAlg: this.hashAlgorithm, | ||
saltLen: this.saltLength, | ||
type: this.type | ||
type: this.type, | ||
}; | ||
}; | ||
return RsaPssParams; | ||
}()); | ||
} | ||
} | ||
exports.RsaPssParams = RsaPssParams; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pkcs11 = require("pkcs11js"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
var MechanismEnum; | ||
@@ -5,0 +6,0 @@ (function (MechanismEnum) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var pkcs11 = require("pkcs11js"); | ||
var int64_buffer_1 = require("int64-buffer"); | ||
var core = require("./core"); | ||
var fs = require("fs"); | ||
var mech_enum_1 = require("./mech_enum"); | ||
const tslib_1 = require("tslib"); | ||
const int64_buffer_1 = require("int64-buffer"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const fs = tslib_1.__importStar(require("fs")); | ||
const core = tslib_1.__importStar(require("./core")); | ||
const mech_enum_1 = require("./mech_enum"); | ||
tslib_1.__exportStar(require("./mech_enum"), exports); | ||
@@ -26,88 +26,80 @@ var MechanismFlag; | ||
})(MechanismFlag = exports.MechanismFlag || (exports.MechanismFlag = {})); | ||
var Mechanism = (function (_super) { | ||
tslib_1.__extends(Mechanism, _super); | ||
function Mechanism(type, handle, slotHandle, lib) { | ||
var _this = _super.call(this, handle, lib) || this; | ||
_this.type = type; | ||
_this.slotHandle = slotHandle; | ||
_this.getInfo(); | ||
return _this; | ||
class Mechanism extends core.HandleObject { | ||
get name() { | ||
return mech_enum_1.MechanismEnum[this.type] || "unknown"; | ||
} | ||
Object.defineProperty(Mechanism.prototype, "name", { | ||
get: function () { | ||
return mech_enum_1.MechanismEnum[this.type] || "unknown"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Mechanism.prototype.getInfo = function () { | ||
var info = this.lib.C_GetMechanismInfo(this.slotHandle, this.type); | ||
this.minKeySize = info.minKeySize; | ||
this.maxKeySize = info.maxKeySize; | ||
this.flags = info.flags; | ||
}; | ||
Mechanism.create = function (alg) { | ||
var res; | ||
var _alg; | ||
if (core.isString(alg)) { | ||
_alg = { name: alg, params: null }; | ||
static create(algorithm) { | ||
let res; | ||
let alg; | ||
if (core.isString(algorithm)) { | ||
alg = { name: algorithm, params: null }; | ||
} | ||
else if (core.isNumber(alg)) { | ||
_alg = { name: mech_enum_1.MechanismEnum[alg], params: null }; | ||
else if (core.isNumber(algorithm)) { | ||
alg = { name: mech_enum_1.MechanismEnum[algorithm], params: null }; | ||
} | ||
else { | ||
_alg = alg; | ||
alg = algorithm; | ||
} | ||
var hAlg = mech_enum_1.MechanismEnum[_alg.name.toUpperCase()]; | ||
if (core.isEmpty(hAlg)) | ||
throw new TypeError("Unknown mechanism name '" + _alg.name + "'"); | ||
var params = null; | ||
if (_alg.params) { | ||
if (_alg.params.toCKI) | ||
params = _alg.params.toCKI(); | ||
else | ||
params = _alg.params; | ||
const hAlg = mech_enum_1.MechanismEnum[alg.name.toUpperCase()]; | ||
if (core.isEmpty(hAlg)) { | ||
throw new TypeError(`Unknown mechanism name '${alg.name}'`); | ||
} | ||
let params = null; | ||
if (alg.params) { | ||
if (alg.params.toCKI) { | ||
params = alg.params.toCKI(); | ||
} | ||
else { | ||
params = alg.params; | ||
} | ||
} | ||
res = { | ||
mechanism: hAlg, | ||
parameter: params | ||
parameter: params, | ||
}; | ||
return res; | ||
}; | ||
Mechanism.vendor = function (name, value) { | ||
var mechs = mech_enum_1.MechanismEnum; | ||
} | ||
static vendor(name, value) { | ||
const mechs = mech_enum_1.MechanismEnum; | ||
if (core.isEmpty(value)) { | ||
var file = fs.readFileSync(name); | ||
var vendor = JSON.parse(file.toString()); | ||
for (var i in vendor) { | ||
var new_name = i; | ||
var v = vendor[i]; | ||
mechs[new_name] = v; | ||
mechs[v] = new_name; | ||
const file = fs.readFileSync(name); | ||
const vendor = JSON.parse(file.toString()); | ||
for (const i in vendor) { | ||
const newName = i; | ||
const v = vendor[i]; | ||
mechs[newName] = v; | ||
mechs[v] = newName; | ||
} | ||
} | ||
else { | ||
var new_name = name; | ||
mechs[new_name] = value; | ||
mechs[value] = new_name; | ||
const newName = name; | ||
mechs[newName] = value; | ||
mechs[value] = newName; | ||
} | ||
}; | ||
return Mechanism; | ||
}(core.HandleObject)); | ||
} | ||
constructor(type, handle, slotHandle, lib) { | ||
super(handle, lib); | ||
this.type = type; | ||
this.slotHandle = slotHandle; | ||
this.getInfo(); | ||
} | ||
getInfo() { | ||
const info = this.lib.C_GetMechanismInfo(this.slotHandle, this.type); | ||
this.minKeySize = info.minKeySize; | ||
this.maxKeySize = info.maxKeySize; | ||
this.flags = info.flags; | ||
} | ||
} | ||
exports.Mechanism = Mechanism; | ||
var MechanismCollection = (function (_super) { | ||
tslib_1.__extends(MechanismCollection, _super); | ||
function MechanismCollection(items, slotHandle, lib, classType) { | ||
if (classType === void 0) { classType = Mechanism; } | ||
var _this = _super.call(this, items, lib, classType) || this; | ||
_this.slotHandle = slotHandle; | ||
return _this; | ||
class MechanismCollection extends core.Collection { | ||
constructor(items, slotHandle, lib, classType = Mechanism) { | ||
super(items, lib, classType); | ||
this.slotHandle = slotHandle; | ||
} | ||
MechanismCollection.prototype.items = function (index) { | ||
var type = this.items_[index]; | ||
var handle = new int64_buffer_1.Int64LE(type).toBuffer(); | ||
items(index) { | ||
const type = this.items_[index]; | ||
const handle = new int64_buffer_1.Int64LE(type).toBuffer(); | ||
return new Mechanism(type, handle, this.slotHandle, this.lib); | ||
}; | ||
return MechanismCollection; | ||
}(core.Collection)); | ||
} | ||
} | ||
exports.MechanismCollection = MechanismCollection; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var pkcs11 = require("pkcs11js"); | ||
var core = require("./core"); | ||
var slot = require("./slot"); | ||
var Module = (function (_super) { | ||
tslib_1.__extends(Module, _super); | ||
function Module(lib) { | ||
var _this = _super.call(this, lib) || this; | ||
_this.libFile = ""; | ||
_this.libName = ""; | ||
return _this; | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const core = tslib_1.__importStar(require("./core")); | ||
const slot = tslib_1.__importStar(require("./slot")); | ||
class Module extends core.BaseObject { | ||
constructor(lib) { | ||
super(lib); | ||
this.libFile = ""; | ||
this.libName = ""; | ||
} | ||
Module.prototype.getInfo = function () { | ||
var info = this.lib.C_GetInfo(); | ||
this.cryptokiVersion = info.cryptokiVersion; | ||
this.manufacturerID = core.removePadding(info.manufacturerID); | ||
this.libraryDescription = core.removePadding(info.libraryDescription); | ||
this.flags = info.flags; | ||
this.libraryVersion = info.libraryVersion; | ||
}; | ||
Module.prototype.initialize = function (options) { | ||
static load(libFile, libName) { | ||
const lib = new pkcs11.PKCS11(); | ||
lib.load(libFile); | ||
const module = new Module(lib); | ||
module.libFile = libFile; | ||
module.libName = libName || libFile; | ||
return module; | ||
} | ||
initialize(options) { | ||
this.lib.C_Initialize(options); | ||
this.getInfo(); | ||
}; | ||
Module.prototype.finalize = function () { | ||
} | ||
finalize() { | ||
this.lib.C_Finalize(); | ||
}; | ||
Module.prototype.getSlots = function (index, tokenPresent) { | ||
if (tokenPresent === void 0) { tokenPresent = true; } | ||
} | ||
getSlots(index, tokenPresent = true) { | ||
if (!core.isEmpty(index) && core.isBoolean(index)) { | ||
tokenPresent = index; | ||
} | ||
var arr = this.lib.C_GetSlotList(tokenPresent); | ||
var col = new slot.SlotCollection(arr, this, this.lib); | ||
const arr = this.lib.C_GetSlotList(tokenPresent); | ||
const col = new slot.SlotCollection(arr, this, this.lib); | ||
if (core.isNumber(index)) { | ||
@@ -41,16 +38,15 @@ return col.items(index); | ||
return col; | ||
}; | ||
Module.prototype.close = function () { | ||
} | ||
close() { | ||
this.lib.close(); | ||
}; | ||
Module.load = function (libFile, libName) { | ||
var lib = new pkcs11.PKCS11(); | ||
lib.load(libFile); | ||
var module = new Module(lib); | ||
module.libFile = libFile; | ||
module.libName = libName || libFile; | ||
return module; | ||
}; | ||
return Module; | ||
}(core.BaseObject)); | ||
} | ||
getInfo() { | ||
const info = this.lib.C_GetInfo(); | ||
this.cryptokiVersion = info.cryptokiVersion; | ||
this.manufacturerID = core.removePadding(info.manufacturerID); | ||
this.libraryDescription = core.removePadding(info.libraryDescription); | ||
this.flags = info.flags; | ||
this.libraryVersion = info.libraryVersion; | ||
} | ||
} | ||
exports.Module = Module; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var pkcs11 = require("pkcs11js"); | ||
var core = require("./core"); | ||
var template_1 = require("./template"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const core = tslib_1.__importStar(require("./core")); | ||
const template_1 = require("./template"); | ||
var ObjectClass; | ||
@@ -19,42 +19,35 @@ (function (ObjectClass) { | ||
})(ObjectClass = exports.ObjectClass || (exports.ObjectClass = {})); | ||
var SessionObject = (function (_super) { | ||
tslib_1.__extends(SessionObject, _super); | ||
function SessionObject(handle, session, lib) { | ||
var _this = this; | ||
class SessionObject extends core.HandleObject { | ||
get size() { | ||
return this.lib.C_GetObjectSize(this.session.handle, this.handle); | ||
} | ||
constructor(handle, session, lib) { | ||
if (handle instanceof SessionObject) { | ||
var obj = handle; | ||
_this = _super.call(this, obj.handle, obj.lib) || this; | ||
_this.session = obj.session; | ||
const obj = handle; | ||
super(obj.handle, obj.lib); | ||
this.session = obj.session; | ||
} | ||
else { | ||
_this = _super.call(this, handle, lib) || this; | ||
_this.session = session; | ||
super(handle, lib); | ||
this.session = session; | ||
} | ||
return _this; | ||
} | ||
Object.defineProperty(SessionObject.prototype, "size", { | ||
get: function () { | ||
return this.lib.C_GetObjectSize(this.session.handle, this.handle); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
SessionObject.prototype.copy = function (template) { | ||
var tmpl = template_1.Template.toPkcs11(template); | ||
var hObject = this.lib.C_CopyObject(this.session.handle, this.handle, tmpl); | ||
copy(template) { | ||
const tmpl = template_1.Template.toPkcs11(template); | ||
const hObject = this.lib.C_CopyObject(this.session.handle, this.handle, tmpl); | ||
return new SessionObject(hObject, this.session, this.lib); | ||
}; | ||
SessionObject.prototype.destroy = function () { | ||
} | ||
destroy() { | ||
this.lib.C_DestroyObject(this.session.handle, this.handle); | ||
}; | ||
SessionObject.prototype.getAttribute = function (attrs) { | ||
var _attrs; | ||
} | ||
getAttribute(attrs) { | ||
let template; | ||
if (typeof attrs === "string") { | ||
_attrs = {}; | ||
_attrs[attrs] = null; | ||
template = {}; | ||
template[attrs] = null; | ||
} | ||
else { | ||
_attrs = attrs; | ||
template = attrs; | ||
} | ||
var tmpl = template_1.Template.toPkcs11(_attrs); | ||
let tmpl = template_1.Template.toPkcs11(template); | ||
tmpl = this.lib.C_GetAttributeValue(this.session.handle, this.handle, tmpl); | ||
@@ -65,34 +58,30 @@ if (typeof attrs === "string") { | ||
return template_1.Template.fromPkcs11(tmpl); | ||
}; | ||
SessionObject.prototype.setAttribute = function (attrs, value) { | ||
} | ||
setAttribute(attrs, value) { | ||
if (core.isString(attrs)) { | ||
var tmp = {}; | ||
const tmp = {}; | ||
tmp[attrs] = value; | ||
attrs = tmp; | ||
} | ||
var tmpl = template_1.Template.toPkcs11(attrs); | ||
const tmpl = template_1.Template.toPkcs11(attrs); | ||
this.lib.C_SetAttributeValue(this.session.handle, this.handle, tmpl); | ||
}; | ||
SessionObject.prototype.get = function (name) { | ||
var tmpl = {}; | ||
} | ||
get(name) { | ||
const tmpl = {}; | ||
tmpl[name] = null; | ||
return this.getAttribute(tmpl)[name]; | ||
}; | ||
SessionObject.prototype.set = function (name, value) { | ||
var tmpl = {}; | ||
} | ||
set(name, value) { | ||
const tmpl = {}; | ||
tmpl[name] = value; | ||
this.setAttribute(tmpl); | ||
}; | ||
Object.defineProperty(SessionObject.prototype, "class", { | ||
get: function () { | ||
return this.get("class"); | ||
}, | ||
set: function (v) { | ||
this.set("class", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
SessionObject.prototype.toType = function () { | ||
var c = this.class; | ||
} | ||
get class() { | ||
return this.get("class"); | ||
} | ||
set class(v) { | ||
this.set("class", v); | ||
} | ||
toType() { | ||
const c = this.class; | ||
switch (c) { | ||
@@ -104,4 +93,4 @@ case ObjectClass.DATA: | ||
case ObjectClass.CERTIFICATE: | ||
var cert = new objects.Certificate(this); | ||
var t = cert.type; | ||
const cert = new objects.Certificate(this); | ||
const t = cert.type; | ||
switch (t) { | ||
@@ -115,3 +104,3 @@ case objects.CertificateType.X_509: | ||
default: | ||
throw new Error("Unknown certificate (CKC_?) type '" + t + "'"); | ||
throw new Error(`Unknown certificate (CKC_?) type '${t}'`); | ||
} | ||
@@ -126,26 +115,21 @@ case ObjectClass.PRIVATE_KEY: | ||
case ObjectClass.OTP_KEY: | ||
throw new Error("Type converter for " + ObjectClass[c] + " is not implemented"); | ||
throw new Error(`Type converter for ${ObjectClass[c]} is not implemented`); | ||
default: | ||
throw new Error("Unknown session object (CKO_?) type '" + c + "'"); | ||
throw new Error(`Unknown session object (CKO_?) type '${c}'`); | ||
} | ||
}; | ||
return SessionObject; | ||
}(core.HandleObject)); | ||
} | ||
} | ||
exports.SessionObject = SessionObject; | ||
var SessionObjectCollection = (function (_super) { | ||
tslib_1.__extends(SessionObjectCollection, _super); | ||
function SessionObjectCollection(items, session, lib, classType) { | ||
if (classType === void 0) { classType = SessionObject; } | ||
var _this = _super.call(this, items, lib, classType) || this; | ||
_this.session = session; | ||
return _this; | ||
class SessionObjectCollection extends core.Collection { | ||
constructor(items, session, lib, classType = SessionObject) { | ||
super(items, lib, classType); | ||
this.session = session; | ||
} | ||
SessionObjectCollection.prototype.items = function (index) { | ||
items(index) { | ||
return new SessionObject(this.items_[index], this.session, this.lib); | ||
}; | ||
return SessionObjectCollection; | ||
}(core.Collection)); | ||
} | ||
} | ||
exports.SessionObjectCollection = SessionObjectCollection; | ||
var objects = require("./objects/common"); | ||
tslib_1.__exportStar(require("./objects/common"), exports); | ||
tslib_1.__exportStar(require("./keys/common"), exports); | ||
const objects = tslib_1.__importStar(require("./objects")); | ||
tslib_1.__exportStar(require("./objects"), exports); | ||
tslib_1.__exportStar(require("./keys"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var cert_1 = require("./cert"); | ||
var AttributeCertificate = (function (_super) { | ||
tslib_1.__extends(AttributeCertificate, _super); | ||
function AttributeCertificate() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const cert_1 = require("./cert"); | ||
class AttributeCertificate extends cert_1.Certificate { | ||
get owner() { | ||
return this.get("owner"); | ||
} | ||
Object.defineProperty(AttributeCertificate.prototype, "owner", { | ||
get: function () { | ||
return this.get("owner"); | ||
}, | ||
set: function (v) { | ||
this.set("owner", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(AttributeCertificate.prototype, "issuer", { | ||
get: function () { | ||
return this.get("issuerAC"); | ||
}, | ||
set: function (v) { | ||
this.set("issuerAC", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(AttributeCertificate.prototype, "serialNumber", { | ||
get: function () { | ||
return this.get("serial"); | ||
}, | ||
set: function (v) { | ||
this.set("serial", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(AttributeCertificate.prototype, "types", { | ||
get: function () { | ||
return this.get("attrTypes"); | ||
}, | ||
set: function (v) { | ||
this.set("attrTypes", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(AttributeCertificate.prototype, "value", { | ||
get: function () { | ||
return this.get("value"); | ||
}, | ||
set: function (v) { | ||
this.set("value", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return AttributeCertificate; | ||
}(cert_1.Certificate)); | ||
set owner(v) { | ||
this.set("owner", v); | ||
} | ||
get issuer() { | ||
return this.get("issuerAC"); | ||
} | ||
set issuer(v) { | ||
this.set("issuerAC", v); | ||
} | ||
get serialNumber() { | ||
return this.get("serial"); | ||
} | ||
set serialNumber(v) { | ||
this.set("serial", v); | ||
} | ||
get types() { | ||
return this.get("attrTypes"); | ||
} | ||
set types(v) { | ||
this.set("attrTypes", v); | ||
} | ||
get value() { | ||
return this.get("value"); | ||
} | ||
set value(v) { | ||
this.set("value", v); | ||
} | ||
} | ||
exports.AttributeCertificate = AttributeCertificate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var pkcs11 = require("pkcs11js"); | ||
var storage_1 = require("../storage"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const storage_1 = require("../storage"); | ||
var CertificateType; | ||
@@ -19,69 +19,40 @@ (function (CertificateType) { | ||
})(CertificateCategory = exports.CertificateCategory || (exports.CertificateCategory = {})); | ||
var Certificate = (function (_super) { | ||
tslib_1.__extends(Certificate, _super); | ||
function Certificate() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
class Certificate extends storage_1.Storage { | ||
get type() { | ||
return this.get("certType"); | ||
} | ||
Object.defineProperty(Certificate.prototype, "type", { | ||
get: function () { | ||
return this.get("certType"); | ||
}, | ||
set: function (v) { | ||
this.set("certType", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Certificate.prototype, "trusted", { | ||
get: function () { | ||
return this.get("trusted"); | ||
}, | ||
set: function (v) { | ||
this.set("trusted", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Certificate.prototype, "category", { | ||
get: function () { | ||
return this.get("certCategory"); | ||
}, | ||
set: function (v) { | ||
this.set("certCategory", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Certificate.prototype, "checkValue", { | ||
get: function () { | ||
return this.get("checkValue"); | ||
}, | ||
set: function (v) { | ||
this.set("checkValue", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Certificate.prototype, "startDate", { | ||
get: function () { | ||
return this.get("startDate"); | ||
}, | ||
set: function (v) { | ||
this.set("startDate", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Certificate.prototype, "endDate", { | ||
get: function () { | ||
return this.get("endDate"); | ||
}, | ||
set: function (v) { | ||
this.set("endDate", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Certificate; | ||
}(storage_1.Storage)); | ||
set type(v) { | ||
this.set("certType", v); | ||
} | ||
get trusted() { | ||
return this.get("trusted"); | ||
} | ||
set trusted(v) { | ||
this.set("trusted", v); | ||
} | ||
get category() { | ||
return this.get("certCategory"); | ||
} | ||
set category(v) { | ||
this.set("certCategory", v); | ||
} | ||
get checkValue() { | ||
return this.get("checkValue"); | ||
} | ||
set checkValue(v) { | ||
this.set("checkValue", v); | ||
} | ||
get startDate() { | ||
return this.get("startDate"); | ||
} | ||
set startDate(v) { | ||
this.set("startDate", v); | ||
} | ||
get endDate() { | ||
return this.get("endDate"); | ||
} | ||
set endDate(v) { | ||
this.set("endDate", v); | ||
} | ||
} | ||
exports.Certificate = Certificate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var cert_1 = require("./cert"); | ||
var WtlsCertificate = (function (_super) { | ||
tslib_1.__extends(WtlsCertificate, _super); | ||
function WtlsCertificate() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const cert_1 = require("./cert"); | ||
class WtlsCertificate extends cert_1.Certificate { | ||
get subject() { | ||
return this.get("subject"); | ||
} | ||
Object.defineProperty(WtlsCertificate.prototype, "subject", { | ||
get: function () { | ||
return this.get("subject"); | ||
}, | ||
set: function (v) { | ||
this.set("subject", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "issuer", { | ||
get: function () { | ||
return this.get("issuer"); | ||
}, | ||
set: function (v) { | ||
this.set("issuer", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "id", { | ||
get: function () { | ||
return this.get("id"); | ||
}, | ||
set: function (v) { | ||
this.set("id", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "value", { | ||
get: function () { | ||
return this.get("value"); | ||
}, | ||
set: function (v) { | ||
this.set("value", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "url", { | ||
get: function () { | ||
return this.get("url"); | ||
}, | ||
set: function (v) { | ||
this.set("url", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "serialNumber", { | ||
get: function () { | ||
return this.get("serial"); | ||
}, | ||
set: function (v) { | ||
this.set("serial", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "subjectKeyIdentifier", { | ||
get: function () { | ||
return this.get("ski"); | ||
}, | ||
set: function (v) { | ||
this.set("ski", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WtlsCertificate.prototype, "authorityKeyIdentifier", { | ||
get: function () { | ||
return this.get("aki"); | ||
}, | ||
set: function (v) { | ||
this.set("aki", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return WtlsCertificate; | ||
}(cert_1.Certificate)); | ||
set subject(v) { | ||
this.set("subject", v); | ||
} | ||
get issuer() { | ||
return this.get("issuer"); | ||
} | ||
set issuer(v) { | ||
this.set("issuer", v); | ||
} | ||
get id() { | ||
return this.get("id"); | ||
} | ||
set id(v) { | ||
this.set("id", v); | ||
} | ||
get value() { | ||
return this.get("value"); | ||
} | ||
set value(v) { | ||
this.set("value", v); | ||
} | ||
get url() { | ||
return this.get("url"); | ||
} | ||
set url(v) { | ||
this.set("url", v); | ||
} | ||
get serialNumber() { | ||
return this.get("serial"); | ||
} | ||
set serialNumber(v) { | ||
this.set("serial", v); | ||
} | ||
get subjectKeyIdentifier() { | ||
return this.get("ski"); | ||
} | ||
set subjectKeyIdentifier(v) { | ||
this.set("ski", v); | ||
} | ||
get authorityKeyIdentifier() { | ||
return this.get("aki"); | ||
} | ||
set authorityKeyIdentifier(v) { | ||
this.set("aki", v); | ||
} | ||
} | ||
exports.WtlsCertificate = WtlsCertificate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var cert_1 = require("./cert"); | ||
const cert_1 = require("./cert"); | ||
var JavaMIDP; | ||
@@ -12,99 +11,58 @@ (function (JavaMIDP) { | ||
})(JavaMIDP = exports.JavaMIDP || (exports.JavaMIDP = {})); | ||
var X509Certificate = (function (_super) { | ||
tslib_1.__extends(X509Certificate, _super); | ||
function X509Certificate() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
class X509Certificate extends cert_1.Certificate { | ||
get subject() { | ||
return this.get("subject"); | ||
} | ||
Object.defineProperty(X509Certificate.prototype, "subject", { | ||
get: function () { | ||
return this.get("subject"); | ||
}, | ||
set: function (v) { | ||
this.set("subject", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "id", { | ||
get: function () { | ||
return this.get("id"); | ||
}, | ||
set: function (v) { | ||
this.set("id", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "issuer", { | ||
get: function () { | ||
return this.get("issuer"); | ||
}, | ||
set: function (v) { | ||
this.set("issuer", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "serialNumber", { | ||
get: function () { | ||
return this.get("serial").toString("hex"); | ||
}, | ||
set: function (v) { | ||
this.set("serial", new Buffer(v, "hex")); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "value", { | ||
get: function () { | ||
return this.get("value"); | ||
}, | ||
set: function (v) { | ||
this.set("value", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "url", { | ||
get: function () { | ||
return this.get("url"); | ||
}, | ||
set: function (v) { | ||
this.set("url", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "subjectKeyIdentifier", { | ||
get: function () { | ||
return this.get("ski"); | ||
}, | ||
set: function (v) { | ||
this.set("ski", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "authorityKeyIdentifier", { | ||
get: function () { | ||
return this.get("aki"); | ||
}, | ||
set: function (v) { | ||
this.set("aki", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(X509Certificate.prototype, "java", { | ||
get: function () { | ||
return this.get("javaDomain"); | ||
}, | ||
set: function (v) { | ||
this.set("javaDomain", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return X509Certificate; | ||
}(cert_1.Certificate)); | ||
set subject(v) { | ||
this.set("subject", v); | ||
} | ||
get id() { | ||
return this.get("id"); | ||
} | ||
set id(v) { | ||
this.set("id", v); | ||
} | ||
get issuer() { | ||
return this.get("issuer"); | ||
} | ||
set issuer(v) { | ||
this.set("issuer", v); | ||
} | ||
get serialNumber() { | ||
return this.get("serial").toString("hex"); | ||
} | ||
set serialNumber(v) { | ||
this.set("serial", Buffer.from(v, "hex")); | ||
} | ||
get value() { | ||
return this.get("value"); | ||
} | ||
set value(v) { | ||
this.set("value", v); | ||
} | ||
get url() { | ||
return this.get("url"); | ||
} | ||
set url(v) { | ||
this.set("url", v); | ||
} | ||
get subjectKeyIdentifier() { | ||
return this.get("ski"); | ||
} | ||
set subjectKeyIdentifier(v) { | ||
this.set("ski", v); | ||
} | ||
get authorityKeyIdentifier() { | ||
return this.get("aki"); | ||
} | ||
set authorityKeyIdentifier(v) { | ||
this.set("aki", v); | ||
} | ||
get java() { | ||
return this.get("javaDomain"); | ||
} | ||
set java(v) { | ||
this.set("javaDomain", v); | ||
} | ||
} | ||
exports.X509Certificate = X509Certificate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var storage_1 = require("./storage"); | ||
var Data = (function (_super) { | ||
tslib_1.__extends(Data, _super); | ||
function Data() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const storage_1 = require("./storage"); | ||
class Data extends storage_1.Storage { | ||
get application() { | ||
return this.get("application"); | ||
} | ||
Object.defineProperty(Data.prototype, "application", { | ||
get: function () { | ||
return this.get("application"); | ||
}, | ||
set: function (v) { | ||
this.set("application", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Data.prototype, "objectId", { | ||
get: function () { | ||
return this.get("objectId"); | ||
}, | ||
set: function (v) { | ||
this.set("objectId", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Data.prototype, "value", { | ||
get: function () { | ||
return this.get("value"); | ||
}, | ||
set: function (v) { | ||
this.set("value", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Data; | ||
}(storage_1.Storage)); | ||
set application(v) { | ||
this.set("application", v); | ||
} | ||
get objectId() { | ||
return this.get("objectId"); | ||
} | ||
set objectId(v) { | ||
this.set("objectId", v); | ||
} | ||
get value() { | ||
return this.get("value"); | ||
} | ||
set value(v) { | ||
this.set("value", v); | ||
} | ||
} | ||
exports.Data = Data; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var storage_1 = require("./storage"); | ||
var DomainParameters = (function (_super) { | ||
tslib_1.__extends(DomainParameters, _super); | ||
function DomainParameters() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const storage_1 = require("./storage"); | ||
class DomainParameters extends storage_1.Storage { | ||
get keyType() { | ||
return this.get("keyType"); | ||
} | ||
Object.defineProperty(DomainParameters.prototype, "keyType", { | ||
get: function () { | ||
return this.get("keyType"); | ||
}, | ||
set: function (v) { | ||
this.set("keyType", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(DomainParameters.prototype, "local", { | ||
get: function () { | ||
return this.get("local"); | ||
}, | ||
set: function (v) { | ||
this.set("local", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return DomainParameters; | ||
}(storage_1.Storage)); | ||
set keyType(v) { | ||
this.set("keyType", v); | ||
} | ||
get local() { | ||
return this.get("local"); | ||
} | ||
set local(v) { | ||
this.set("local", v); | ||
} | ||
} | ||
exports.DomainParameters = DomainParameters; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var storage_1 = require("../storage"); | ||
var pkcs11 = require("pkcs11js"); | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const storage_1 = require("../storage"); | ||
var KeyType; | ||
@@ -77,94 +77,57 @@ (function (KeyType) { | ||
})(KeyGenMechanism = exports.KeyGenMechanism || (exports.KeyGenMechanism = {})); | ||
var Key = (function (_super) { | ||
tslib_1.__extends(Key, _super); | ||
function Key() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
class Key extends storage_1.Storage { | ||
get type() { | ||
return this.get("keyType"); | ||
} | ||
Object.defineProperty(Key.prototype, "type", { | ||
get: function () { | ||
return this.get("keyType"); | ||
}, | ||
set: function (v) { | ||
this.set("keyType", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "id", { | ||
get: function () { | ||
return this.get("id"); | ||
}, | ||
set: function (v) { | ||
this.set("id", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "startDate", { | ||
get: function () { | ||
return this.get("startDate"); | ||
}, | ||
set: function (v) { | ||
this.set("startDate", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "endDate", { | ||
get: function () { | ||
return this.get("endDate"); | ||
}, | ||
set: function (v) { | ||
this.set("endDate", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "derive", { | ||
get: function () { | ||
try { | ||
return this.get("derive"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("derive", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "local", { | ||
get: function () { | ||
return this.get("local"); | ||
}, | ||
set: function (v) { | ||
this.set("local", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "mechanism", { | ||
get: function () { | ||
return this.get("keyGenMechanism"); | ||
}, | ||
set: function (v) { | ||
this.set("keyGenMechanism", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Key.prototype, "allowedMechanisms", { | ||
get: function () { | ||
throw "Not implemented"; | ||
}, | ||
set: function (v) { | ||
throw "Not implemented"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Key; | ||
}(storage_1.Storage)); | ||
set type(v) { | ||
this.set("keyType", v); | ||
} | ||
get id() { | ||
return this.get("id"); | ||
} | ||
set id(v) { | ||
this.set("id", v); | ||
} | ||
get startDate() { | ||
return this.get("startDate"); | ||
} | ||
set startDate(v) { | ||
this.set("startDate", v); | ||
} | ||
get endDate() { | ||
return this.get("endDate"); | ||
} | ||
set endDate(v) { | ||
this.set("endDate", v); | ||
} | ||
get derive() { | ||
try { | ||
return this.get("derive"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set derive(v) { | ||
this.set("derive", v); | ||
} | ||
get local() { | ||
return this.get("local"); | ||
} | ||
set local(v) { | ||
this.set("local", v); | ||
} | ||
get mechanism() { | ||
return this.get("keyGenMechanism"); | ||
} | ||
set mechanism(v) { | ||
this.set("keyGenMechanism", v); | ||
} | ||
get allowedMechanisms() { | ||
throw new Error("Not implemented"); | ||
} | ||
set allowedMechanisms(v) { | ||
throw new Error("Not implemented"); | ||
} | ||
} | ||
exports.Key = Key; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var key_1 = require("./key"); | ||
var PrivateKey = (function (_super) { | ||
tslib_1.__extends(PrivateKey, _super); | ||
function PrivateKey() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const key_1 = require("./key"); | ||
class PrivateKey extends key_1.Key { | ||
get subject() { | ||
return this.get("subject"); | ||
} | ||
Object.defineProperty(PrivateKey.prototype, "subject", { | ||
get: function () { | ||
return this.get("subject"); | ||
}, | ||
set: function (v) { | ||
this.set("subject", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "sensitive", { | ||
get: function () { | ||
return this.get("sensitive"); | ||
}, | ||
set: function (v) { | ||
this.set("sensitive", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "decrypt", { | ||
get: function () { | ||
try { | ||
return this.get("decrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("decrypt", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "sign", { | ||
get: function () { | ||
try { | ||
return this.get("sign"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("sign", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "signRecover", { | ||
get: function () { | ||
try { | ||
return this.get("signRecover"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("signRecover", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "unwrap", { | ||
get: function () { | ||
try { | ||
return this.get("unwrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("unwrap", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "extractable", { | ||
get: function () { | ||
return this.get("extractable"); | ||
}, | ||
set: function (v) { | ||
this.set("extractable", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "alwaysSensitive", { | ||
get: function () { | ||
return this.get("alwaysSensitive "); | ||
}, | ||
set: function (v) { | ||
this.set("alwaysSensitive", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "neverExtractable", { | ||
get: function () { | ||
return this.get("neverExtractable"); | ||
}, | ||
set: function (v) { | ||
this.set("neverExtractable", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "wrapTrusted", { | ||
get: function () { | ||
return this.get("wrapWithTrusted"); | ||
}, | ||
set: function (v) { | ||
this.set("wrapWithTrusted", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "template", { | ||
get: function () { | ||
throw new Error("Not implemented"); | ||
}, | ||
set: function (v) { | ||
throw new Error("Not implemented"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PrivateKey.prototype, "alwaysAuthenticate", { | ||
get: function () { | ||
return this.get("alwaysAuth"); | ||
}, | ||
set: function (v) { | ||
this.set("alwaysAuth", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return PrivateKey; | ||
}(key_1.Key)); | ||
set subject(v) { | ||
this.set("subject", v); | ||
} | ||
get sensitive() { | ||
return this.get("sensitive"); | ||
} | ||
set sensitive(v) { | ||
this.set("sensitive", v); | ||
} | ||
get decrypt() { | ||
try { | ||
return this.get("decrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set decrypt(v) { | ||
this.set("decrypt", v); | ||
} | ||
get sign() { | ||
try { | ||
return this.get("sign"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set sign(v) { | ||
this.set("sign", v); | ||
} | ||
get signRecover() { | ||
try { | ||
return this.get("signRecover"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set signRecover(v) { | ||
this.set("signRecover", v); | ||
} | ||
get unwrap() { | ||
try { | ||
return this.get("unwrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set unwrap(v) { | ||
this.set("unwrap", v); | ||
} | ||
get extractable() { | ||
return this.get("extractable"); | ||
} | ||
set extractable(v) { | ||
this.set("extractable", v); | ||
} | ||
get alwaysSensitive() { | ||
return this.get("alwaysSensitive "); | ||
} | ||
set alwaysSensitive(v) { | ||
this.set("alwaysSensitive", v); | ||
} | ||
get neverExtractable() { | ||
return this.get("neverExtractable"); | ||
} | ||
set neverExtractable(v) { | ||
this.set("neverExtractable", v); | ||
} | ||
get wrapTrusted() { | ||
return this.get("wrapWithTrusted"); | ||
} | ||
set wrapTrusted(v) { | ||
this.set("wrapWithTrusted", v); | ||
} | ||
get template() { | ||
throw new Error("Not implemented"); | ||
} | ||
set template(v) { | ||
throw new Error("Not implemented"); | ||
} | ||
get alwaysAuthenticate() { | ||
return this.get("alwaysAuth"); | ||
} | ||
set alwaysAuthenticate(v) { | ||
this.set("alwaysAuth", v); | ||
} | ||
} | ||
exports.PrivateKey = PrivateKey; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var key_1 = require("./key"); | ||
var PublicKey = (function (_super) { | ||
tslib_1.__extends(PublicKey, _super); | ||
function PublicKey() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const key_1 = require("./key"); | ||
class PublicKey extends key_1.Key { | ||
get subject() { | ||
return this.get("subject"); | ||
} | ||
Object.defineProperty(PublicKey.prototype, "subject", { | ||
get: function () { | ||
return this.get("subject"); | ||
}, | ||
set: function (v) { | ||
this.set("subject", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "encrypt", { | ||
get: function () { | ||
try { | ||
return this.get("encrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("encrypt", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "verify", { | ||
get: function () { | ||
try { | ||
return this.get("verify"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("verify", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "verifyRecover", { | ||
get: function () { | ||
try { | ||
return this.get("verifyRecover"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("verifyRecover", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "wrap", { | ||
get: function () { | ||
try { | ||
return this.get("wrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("wrap", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "trusted", { | ||
get: function () { | ||
return this.get("trusted"); | ||
}, | ||
set: function (v) { | ||
this.set("trusted", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(PublicKey.prototype, "template", { | ||
get: function () { | ||
throw new Error("Not implemented"); | ||
}, | ||
set: function (v) { | ||
throw new Error("Not implemented"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return PublicKey; | ||
}(key_1.Key)); | ||
set subject(v) { | ||
this.set("subject", v); | ||
} | ||
get encrypt() { | ||
try { | ||
return this.get("encrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set encrypt(v) { | ||
this.set("encrypt", v); | ||
} | ||
get verify() { | ||
try { | ||
return this.get("verify"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set verify(v) { | ||
this.set("verify", v); | ||
} | ||
get verifyRecover() { | ||
try { | ||
return this.get("verifyRecover"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set verifyRecover(v) { | ||
this.set("verifyRecover", v); | ||
} | ||
get wrap() { | ||
try { | ||
return this.get("wrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set wrap(v) { | ||
this.set("wrap", v); | ||
} | ||
get trusted() { | ||
return this.get("trusted"); | ||
} | ||
set trusted(v) { | ||
this.set("trusted", v); | ||
} | ||
get template() { | ||
throw new Error("Not implemented"); | ||
} | ||
set template(v) { | ||
throw new Error("Not implemented"); | ||
} | ||
} | ||
exports.PublicKey = PublicKey; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var key_1 = require("./key"); | ||
var SecretKey = (function (_super) { | ||
tslib_1.__extends(SecretKey, _super); | ||
function SecretKey() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const key_1 = require("./key"); | ||
class SecretKey extends key_1.Key { | ||
get sensitive() { | ||
return this.get("sensitive"); | ||
} | ||
Object.defineProperty(SecretKey.prototype, "sensitive", { | ||
get: function () { | ||
return this.get("sensitive"); | ||
}, | ||
set: function (v) { | ||
this.set("sensitive", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "encrypt", { | ||
get: function () { | ||
try { | ||
return this.get("encrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("encrypt", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "decrypt", { | ||
get: function () { | ||
try { | ||
return this.get("decrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("decrypt", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "verify", { | ||
get: function () { | ||
try { | ||
return this.get("verify"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("verify", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "sign", { | ||
get: function () { | ||
try { | ||
return this.get("sign"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("sign", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "wrap", { | ||
get: function () { | ||
try { | ||
return this.get("wrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("wrap", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "unwrap", { | ||
get: function () { | ||
try { | ||
return this.get("unwrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}, | ||
set: function (v) { | ||
this.set("unwrap", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "extractable", { | ||
get: function () { | ||
return this.get("extractable"); | ||
}, | ||
set: function (v) { | ||
this.set("extractable", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "alwaysSensitive", { | ||
get: function () { | ||
return this.get("alwaysSensitive "); | ||
}, | ||
set: function (v) { | ||
this.set("alwaysSensitive", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "neverExtractable", { | ||
get: function () { | ||
return this.get("neverExtractable"); | ||
}, | ||
set: function (v) { | ||
this.set("neverExtractable", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "checkValue", { | ||
get: function () { | ||
return this.get("checkValue"); | ||
}, | ||
set: function (v) { | ||
this.set("checkValue", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "wrapTrusted", { | ||
get: function () { | ||
return this.get("wrapWithTrusted"); | ||
}, | ||
set: function (v) { | ||
this.set("wrapWithTrusted", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "trusted", { | ||
get: function () { | ||
return this.get("trusted"); | ||
}, | ||
set: function (v) { | ||
this.set("trusted", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "wrapTemplate", { | ||
get: function () { | ||
throw new Error("Not implemented"); | ||
}, | ||
set: function (v) { | ||
throw new Error("Not implemented"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(SecretKey.prototype, "unwrapTemplate", { | ||
get: function () { | ||
throw new Error("Not implemented"); | ||
}, | ||
set: function (v) { | ||
throw new Error("Not implemented"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return SecretKey; | ||
}(key_1.Key)); | ||
set sensitive(v) { | ||
this.set("sensitive", v); | ||
} | ||
get encrypt() { | ||
try { | ||
return this.get("encrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set encrypt(v) { | ||
this.set("encrypt", v); | ||
} | ||
get decrypt() { | ||
try { | ||
return this.get("decrypt"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set decrypt(v) { | ||
this.set("decrypt", v); | ||
} | ||
get verify() { | ||
try { | ||
return this.get("verify"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set verify(v) { | ||
this.set("verify", v); | ||
} | ||
get sign() { | ||
try { | ||
return this.get("sign"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set sign(v) { | ||
this.set("sign", v); | ||
} | ||
get wrap() { | ||
try { | ||
return this.get("wrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set wrap(v) { | ||
this.set("wrap", v); | ||
} | ||
get unwrap() { | ||
try { | ||
return this.get("unwrap"); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
set unwrap(v) { | ||
this.set("unwrap", v); | ||
} | ||
get extractable() { | ||
return this.get("extractable"); | ||
} | ||
set extractable(v) { | ||
this.set("extractable", v); | ||
} | ||
get alwaysSensitive() { | ||
return this.get("alwaysSensitive "); | ||
} | ||
set alwaysSensitive(v) { | ||
this.set("alwaysSensitive", v); | ||
} | ||
get neverExtractable() { | ||
return this.get("neverExtractable"); | ||
} | ||
set neverExtractable(v) { | ||
this.set("neverExtractable", v); | ||
} | ||
get checkValue() { | ||
return this.get("checkValue"); | ||
} | ||
set checkValue(v) { | ||
this.set("checkValue", v); | ||
} | ||
get wrapTrusted() { | ||
return this.get("wrapWithTrusted"); | ||
} | ||
set wrapTrusted(v) { | ||
this.set("wrapWithTrusted", v); | ||
} | ||
get trusted() { | ||
return this.get("trusted"); | ||
} | ||
set trusted(v) { | ||
this.set("trusted", v); | ||
} | ||
get wrapTemplate() { | ||
throw new Error("Not implemented"); | ||
} | ||
set wrapTemplate(v) { | ||
throw new Error("Not implemented"); | ||
} | ||
get unwrapTemplate() { | ||
throw new Error("Not implemented"); | ||
} | ||
set unwrapTemplate(v) { | ||
throw new Error("Not implemented"); | ||
} | ||
} | ||
exports.SecretKey = SecretKey; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var object_1 = require("../object"); | ||
var Storage = (function (_super) { | ||
tslib_1.__extends(Storage, _super); | ||
function Storage() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
const object_1 = require("../object"); | ||
class Storage extends object_1.SessionObject { | ||
get token() { | ||
return this.get("token"); | ||
} | ||
Object.defineProperty(Storage.prototype, "token", { | ||
get: function () { | ||
return this.get("token"); | ||
}, | ||
set: function (v) { | ||
this.set("token", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Storage.prototype, "private", { | ||
get: function () { | ||
return this.get("private"); | ||
}, | ||
set: function (v) { | ||
this.set("private", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Storage.prototype, "modifiable", { | ||
get: function () { | ||
return this.get("modifiable"); | ||
}, | ||
set: function (v) { | ||
this.set("modifiable", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Storage.prototype, "label", { | ||
get: function () { | ||
return this.get("label"); | ||
}, | ||
set: function (v) { | ||
this.set("label", v); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Storage; | ||
}(object_1.SessionObject)); | ||
set token(v) { | ||
this.set("token", v); | ||
} | ||
get private() { | ||
return this.get("private"); | ||
} | ||
set private(v) { | ||
this.set("private", v); | ||
} | ||
get modifiable() { | ||
return this.get("modifiable"); | ||
} | ||
set modifiable(v) { | ||
this.set("modifiable", v); | ||
} | ||
get label() { | ||
return this.get("label"); | ||
} | ||
set label(v) { | ||
this.set("label", v); | ||
} | ||
} | ||
exports.Storage = Storage; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("./core"); | ||
var object_1 = require("./object"); | ||
var template_1 = require("./template"); | ||
var mech_1 = require("./mech"); | ||
var objects = require("./objects/common"); | ||
var common_1 = require("./crypto/common"); | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("./core")); | ||
const mech_1 = require("./mech"); | ||
const object_1 = require("./object"); | ||
const objects = tslib_1.__importStar(require("./objects")); | ||
const template_1 = require("./template"); | ||
const crypto_1 = require("./crypto"); | ||
var SessionFlag; | ||
@@ -21,51 +21,40 @@ (function (SessionFlag) { | ||
})(UserType = exports.UserType || (exports.UserType = {})); | ||
var Session = (function (_super) { | ||
tslib_1.__extends(Session, _super); | ||
function Session(handle, slot, lib) { | ||
var _this = _super.call(this, handle, lib) || this; | ||
_this.slot = slot; | ||
_this.getInfo(); | ||
return _this; | ||
class Session extends core.HandleObject { | ||
constructor(handle, slot, lib) { | ||
super(handle, lib); | ||
this.slot = slot; | ||
this.getInfo(); | ||
} | ||
Session.prototype.getInfo = function () { | ||
var info = this.lib.C_GetSessionInfo(this.handle); | ||
this.state = info.state; | ||
this.flags = info.flags; | ||
this.deviceError = info.deviceError; | ||
}; | ||
Session.prototype.close = function () { | ||
close() { | ||
this.lib.C_CloseSession(this.handle); | ||
}; | ||
Session.prototype.initPin = function (pin) { | ||
} | ||
initPin(pin) { | ||
this.lib.C_InitPIN(this.handle, pin); | ||
}; | ||
Session.prototype.setPin = function (oldPin, newPin) { | ||
} | ||
setPin(oldPin, newPin) { | ||
this.lib.C_SetPIN(this.handle, oldPin, newPin); | ||
}; | ||
Session.prototype.getOperationState = function () { | ||
} | ||
getOperationState() { | ||
throw new Error("Not implemented"); | ||
}; | ||
Session.prototype.setOperationState = function (state, encryptionKey, authenticationKey) { | ||
if (encryptionKey === void 0) { encryptionKey = 0; } | ||
if (authenticationKey === void 0) { authenticationKey = 0; } | ||
} | ||
setOperationState(state, encryptionKey = 0, authenticationKey = 0) { | ||
throw new Error("Not implemented"); | ||
}; | ||
Session.prototype.login = function (pin, userType) { | ||
if (userType === void 0) { userType = UserType.USER; } | ||
} | ||
login(pin, userType = UserType.USER) { | ||
this.lib.C_Login(this.handle, userType, pin); | ||
}; | ||
Session.prototype.logout = function () { | ||
} | ||
logout() { | ||
this.lib.C_Logout(this.handle); | ||
}; | ||
Session.prototype.create = function (template) { | ||
var tmpl = template_1.Template.toPkcs11(template); | ||
var hObject = this.lib.C_CreateObject(this.handle, tmpl); | ||
} | ||
create(template) { | ||
const tmpl = template_1.Template.toPkcs11(template); | ||
const hObject = this.lib.C_CreateObject(this.handle, tmpl); | ||
return new object_1.SessionObject(hObject, this, this.lib); | ||
}; | ||
Session.prototype.copy = function (object, template) { | ||
var tmpl = template_1.Template.toPkcs11(template); | ||
var hObject = this.lib.C_CopyObject(this.handle, object.handle, tmpl); | ||
} | ||
copy(object, template) { | ||
const tmpl = template_1.Template.toPkcs11(template); | ||
const hObject = this.lib.C_CopyObject(this.handle, object.handle, tmpl); | ||
return new object_1.SessionObject(hObject, this, this.lib); | ||
}; | ||
Session.prototype.destroy = function (param) { | ||
} | ||
destroy(param) { | ||
if (param instanceof object_1.SessionObject) { | ||
@@ -76,5 +65,5 @@ this.lib.C_DestroyObject(this.handle, param.handle); | ||
else { | ||
var objs = this.find(param || null); | ||
var removed = objs.length; | ||
for (var i = 0; i < objs.length; i++) { | ||
const objs = this.find(param || null); | ||
const removed = objs.length; | ||
for (let i = 0; i < objs.length; i++) { | ||
objs.items(i).destroy(); | ||
@@ -84,8 +73,7 @@ } | ||
} | ||
}; | ||
Session.prototype.clear = function () { | ||
} | ||
clear() { | ||
return this.destroy(); | ||
}; | ||
Session.prototype.find = function (template, callback) { | ||
if (template === void 0) { template = null; } | ||
} | ||
find(template = null, callback) { | ||
if (core.isFunction(template)) { | ||
@@ -95,14 +83,15 @@ callback = template; | ||
} | ||
var tmpl = template_1.Template.toPkcs11(template); | ||
const tmpl = template_1.Template.toPkcs11(template); | ||
this.lib.C_FindObjectsInit(this.handle, tmpl); | ||
var objects = []; | ||
const handles = []; | ||
try { | ||
while (true) { | ||
var hObject = this.lib.C_FindObjects(this.handle); | ||
if (!hObject) | ||
const hObject = this.lib.C_FindObjects(this.handle); | ||
if (!hObject) { | ||
break; | ||
if (callback && callback(new object_1.SessionObject(hObject, this, this.lib), objects.length) === false) { | ||
} | ||
if (callback && callback(new object_1.SessionObject(hObject, this, this.lib), handles.length) === false) { | ||
break; | ||
} | ||
objects.push(hObject); | ||
handles.push(hObject); | ||
} | ||
@@ -115,8 +104,8 @@ } | ||
this.lib.C_FindObjectsFinal(this.handle); | ||
return new object_1.SessionObjectCollection(objects, this, this.lib); | ||
}; | ||
Session.prototype.getObject = function (handle) { | ||
var res; | ||
this.find(function (obj) { | ||
var compare = obj.handle.compare(handle); | ||
return new object_1.SessionObjectCollection(handles, this, this.lib); | ||
} | ||
getObject(handle) { | ||
let res; | ||
this.find((obj) => { | ||
const compare = obj.handle.compare(handle); | ||
if (compare === 0) { | ||
@@ -126,21 +115,22 @@ res = obj; | ||
} | ||
if (compare === 1) | ||
if (compare === 1) { | ||
return false; | ||
} | ||
}); | ||
if (res) | ||
if (res) { | ||
return res.toType(); | ||
else | ||
} | ||
else { | ||
return null; | ||
}; | ||
Session.prototype.generateKey = function (mechanism, template, callback) { | ||
var _this = this; | ||
if (template === void 0) { template = null; } | ||
} | ||
} | ||
generateKey(mechanism, template = null, callback) { | ||
try { | ||
var pMech = mech_1.Mechanism.create(mechanism); | ||
const pMech = mech_1.Mechanism.create(mechanism); | ||
if (template) { | ||
template.class = object_1.ObjectClass.SECRET_KEY; | ||
} | ||
var pTemplate = template_1.Template.toPkcs11(template); | ||
const pTemplate = template_1.Template.toPkcs11(template); | ||
if (callback) { | ||
this.lib.C_GenerateKey(this.handle, pMech, pTemplate, function (err, hKey) { | ||
this.lib.C_GenerateKey(this.handle, pMech, pTemplate, (err, hKey) => { | ||
if (err) { | ||
@@ -150,3 +140,3 @@ callback(err, null); | ||
else { | ||
var obj = new object_1.SessionObject(hKey, _this, _this.lib); | ||
const obj = new object_1.SessionObject(hKey, this, this.lib); | ||
callback(null, obj.toType()); | ||
@@ -157,4 +147,4 @@ } | ||
else { | ||
var hKey = this.lib.C_GenerateKey(this.handle, pMech, pTemplate); | ||
var obj = new object_1.SessionObject(hKey, this, this.lib); | ||
const hKey = this.lib.C_GenerateKey(this.handle, pMech, pTemplate); | ||
const obj = new object_1.SessionObject(hKey, this, this.lib); | ||
return obj.toType(); | ||
@@ -164,16 +154,17 @@ } | ||
catch (e) { | ||
if (callback) | ||
if (callback) { | ||
callback(e, null); | ||
else | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
Session.prototype.generateKeyPair = function (mechanism, publicTemplate, privateTemplate, callback) { | ||
var _this = this; | ||
} | ||
generateKeyPair(mechanism, publicTemplate, privateTemplate, callback) { | ||
try { | ||
var pMech = mech_1.Mechanism.create(mechanism); | ||
const pMech = mech_1.Mechanism.create(mechanism); | ||
if (publicTemplate) { | ||
publicTemplate.class = object_1.ObjectClass.PUBLIC_KEY; | ||
} | ||
var pubTmpl = template_1.Template.toPkcs11(publicTemplate); | ||
const pubTmpl = template_1.Template.toPkcs11(publicTemplate); | ||
if (privateTemplate) { | ||
@@ -183,13 +174,15 @@ privateTemplate.class = object_1.ObjectClass.PRIVATE_KEY; | ||
} | ||
var prvTmpl = template_1.Template.toPkcs11(privateTemplate); | ||
const prvTmpl = template_1.Template.toPkcs11(privateTemplate); | ||
if (callback) { | ||
this.lib.C_GenerateKeyPair(this.handle, pMech, pubTmpl, prvTmpl, function (err, keys) { | ||
if (err) | ||
this.lib.C_GenerateKeyPair(this.handle, pMech, pubTmpl, prvTmpl, (err, keys) => { | ||
if (err) { | ||
callback(err, null); | ||
} | ||
else { | ||
if (keys) | ||
if (keys) { | ||
callback(null, { | ||
publicKey: new objects.PublicKey(keys.publicKey, _this, _this.lib), | ||
privateKey: new objects.PrivateKey(keys.privateKey, _this, _this.lib) | ||
publicKey: new objects.PublicKey(keys.publicKey, this, this.lib), | ||
privateKey: new objects.PrivateKey(keys.privateKey, this, this.lib), | ||
}); | ||
} | ||
} | ||
@@ -199,6 +192,6 @@ }); | ||
else { | ||
var keys = this.lib.C_GenerateKeyPair(this.handle, pMech, pubTmpl, prvTmpl); | ||
const keys = this.lib.C_GenerateKeyPair(this.handle, pMech, pubTmpl, prvTmpl); | ||
return { | ||
publicKey: new objects.PublicKey(keys.publicKey, this, this.lib), | ||
privateKey: new objects.PrivateKey(keys.privateKey, this, this.lib) | ||
privateKey: new objects.PrivateKey(keys.privateKey, this, this.lib), | ||
}; | ||
@@ -208,27 +201,29 @@ } | ||
catch (e) { | ||
if (callback) | ||
if (callback) { | ||
callback(e, null); | ||
else | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
Session.prototype.createSign = function (alg, key) { | ||
return new common_1.Sign(this, alg, key, this.lib); | ||
}; | ||
Session.prototype.createVerify = function (alg, key) { | ||
return new common_1.Verify(this, alg, key, this.lib); | ||
}; | ||
Session.prototype.createCipher = function (alg, key) { | ||
return new common_1.Cipher(this, alg, key, this.lib); | ||
}; | ||
Session.prototype.createDecipher = function (alg, key, blockSize) { | ||
return new common_1.Decipher(this, alg, key, blockSize || 0, this.lib); | ||
}; | ||
Session.prototype.createDigest = function (alg) { | ||
return new common_1.Digest(this, alg, this.lib); | ||
}; | ||
Session.prototype.wrapKey = function (alg, wrappingKey, key, callback) { | ||
} | ||
createSign(alg, key) { | ||
return new crypto_1.Sign(this, alg, key, this.lib); | ||
} | ||
createVerify(alg, key) { | ||
return new crypto_1.Verify(this, alg, key, this.lib); | ||
} | ||
createCipher(alg, key) { | ||
return new crypto_1.Cipher(this, alg, key, this.lib); | ||
} | ||
createDecipher(alg, key, blockSize) { | ||
return new crypto_1.Decipher(this, alg, key, blockSize || 0, this.lib); | ||
} | ||
createDigest(alg) { | ||
return new crypto_1.Digest(this, alg, this.lib); | ||
} | ||
wrapKey(alg, wrappingKey, key, callback) { | ||
try { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
var wrappedKey = new Buffer(8096); | ||
const pMech = mech_1.Mechanism.create(alg); | ||
let wrappedKey = Buffer.alloc(8096); | ||
if (callback) { | ||
@@ -243,23 +238,26 @@ this.lib.C_WrapKey(this.handle, pMech, wrappingKey.handle, key.handle, wrappedKey, callback); | ||
catch (e) { | ||
if (callback) | ||
if (callback) { | ||
callback(e, null); | ||
else | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
Session.prototype.unwrapKey = function (alg, unwrappingKey, wrappedKey, template, callback) { | ||
var _this = this; | ||
} | ||
unwrapKey(alg, unwrappingKey, wrappedKey, template, callback) { | ||
try { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
var pTemplate = template_1.Template.toPkcs11(template); | ||
const pMech = mech_1.Mechanism.create(alg); | ||
const pTemplate = template_1.Template.toPkcs11(template); | ||
if (callback) { | ||
this.lib.C_UnwrapKey(this.handle, pMech, unwrappingKey.handle, wrappedKey, pTemplate, function (err, hKey) { | ||
if (err) | ||
this.lib.C_UnwrapKey(this.handle, pMech, unwrappingKey.handle, wrappedKey, pTemplate, (err, hKey) => { | ||
if (err) { | ||
callback(err, null); | ||
else | ||
callback(null, new object_1.Key(hKey, _this, _this.lib)); | ||
} | ||
else { | ||
callback(null, new object_1.Key(hKey, this, this.lib)); | ||
} | ||
}); | ||
} | ||
else { | ||
var hKey = this.lib.C_UnwrapKey(this.handle, pMech, unwrappingKey.handle, wrappedKey, pTemplate); | ||
const hKey = this.lib.C_UnwrapKey(this.handle, pMech, unwrappingKey.handle, wrappedKey, pTemplate); | ||
return new object_1.Key(hKey, this, this.lib); | ||
@@ -269,23 +267,26 @@ } | ||
catch (e) { | ||
if (callback) | ||
if (callback) { | ||
callback(e, null); | ||
else | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
Session.prototype.deriveKey = function (alg, baseKey, template, callback) { | ||
var _this = this; | ||
} | ||
deriveKey(alg, baseKey, template, callback) { | ||
try { | ||
var pMech = mech_1.Mechanism.create(alg); | ||
var pTemplate = template_1.Template.toPkcs11(template); | ||
const pMech = mech_1.Mechanism.create(alg); | ||
const pTemplate = template_1.Template.toPkcs11(template); | ||
if (callback) { | ||
this.lib.C_DeriveKey(this.handle, pMech, baseKey.handle, pTemplate, function (err, hKey) { | ||
if (err) | ||
this.lib.C_DeriveKey(this.handle, pMech, baseKey.handle, pTemplate, (err, hKey) => { | ||
if (err) { | ||
callback(err, null); | ||
else | ||
callback(null, new object_1.SecretKey(hKey, _this, _this.lib)); | ||
} | ||
else { | ||
callback(null, new object_1.SecretKey(hKey, this, this.lib)); | ||
} | ||
}); | ||
} | ||
else { | ||
var hKey = this.lib.C_DeriveKey(this.handle, pMech, baseKey.handle, pTemplate); | ||
const hKey = this.lib.C_DeriveKey(this.handle, pMech, baseKey.handle, pTemplate); | ||
return new object_1.SecretKey(hKey, this, this.lib); | ||
@@ -298,13 +299,19 @@ } | ||
} | ||
else | ||
else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
Session.prototype.generateRandom = function (size) { | ||
var buf = new Buffer(size); | ||
} | ||
generateRandom(size) { | ||
const buf = Buffer.alloc(size); | ||
this.lib.C_GenerateRandom(this.handle, buf); | ||
return buf; | ||
}; | ||
return Session; | ||
}(core.HandleObject)); | ||
} | ||
getInfo() { | ||
const info = this.lib.C_GetSessionInfo(this.handle); | ||
this.state = info.state; | ||
this.flags = info.flags; | ||
this.deviceError = info.deviceError; | ||
} | ||
} | ||
exports.Session = Session; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("./core"); | ||
var token = require("./token"); | ||
var mech = require("./mech"); | ||
var session = require("./session"); | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("./core")); | ||
const mech = tslib_1.__importStar(require("./mech")); | ||
const session = tslib_1.__importStar(require("./session")); | ||
const token = tslib_1.__importStar(require("./token")); | ||
var SlotFlag; | ||
@@ -14,12 +14,27 @@ (function (SlotFlag) { | ||
})(SlotFlag = exports.SlotFlag || (exports.SlotFlag = {})); | ||
var Slot = (function (_super) { | ||
tslib_1.__extends(Slot, _super); | ||
function Slot(handle, module, lib) { | ||
var _this = _super.call(this, handle, lib) || this; | ||
_this.module = module; | ||
_this.getInfo(); | ||
return _this; | ||
class Slot extends core.HandleObject { | ||
constructor(handle, module, lib) { | ||
super(handle, lib); | ||
this.module = module; | ||
this.getInfo(); | ||
} | ||
Slot.prototype.getInfo = function () { | ||
var info = this.lib.C_GetSlotInfo(this.handle); | ||
getToken() { | ||
return new token.Token(this.handle, this.lib); | ||
} | ||
getMechanisms() { | ||
const arr = this.lib.C_GetMechanismList(this.handle); | ||
return new mech.MechanismCollection(arr, this.handle, this.lib); | ||
} | ||
initToken(pin, label = "") { | ||
return this.lib.C_InitToken(this.handle, pin, label); | ||
} | ||
open(flags = session.SessionFlag.SERIAL_SESSION) { | ||
const hSession = this.lib.C_OpenSession(this.handle, flags); | ||
return new session.Session(hSession, this, this.lib); | ||
} | ||
closeAll() { | ||
this.lib.C_CloseAllSessions(this.handle); | ||
} | ||
getInfo() { | ||
const info = this.lib.C_GetSlotInfo(this.handle); | ||
this.slotDescription = core.removePadding(info.slotDescription); | ||
@@ -30,38 +45,14 @@ this.manufacturerID = core.removePadding(info.manufacturerID); | ||
this.firmwareVersion = info.firmwareVersion; | ||
}; | ||
Slot.prototype.getToken = function () { | ||
return new token.Token(this.handle, this.lib); | ||
}; | ||
Slot.prototype.getMechanisms = function () { | ||
var arr = this.lib.C_GetMechanismList(this.handle); | ||
return new mech.MechanismCollection(arr, this.handle, this.lib); | ||
}; | ||
Slot.prototype.initToken = function (pin, label) { | ||
if (label === void 0) { label = ''; } | ||
return this.lib.C_InitToken(this.handle, pin, label); | ||
}; | ||
Slot.prototype.open = function (flags) { | ||
if (flags === void 0) { flags = session.SessionFlag.SERIAL_SESSION; } | ||
var hSession = this.lib.C_OpenSession(this.handle, flags); | ||
return new session.Session(hSession, this, this.lib); | ||
}; | ||
Slot.prototype.closeAll = function () { | ||
this.lib.C_CloseAllSessions(this.handle); | ||
}; | ||
return Slot; | ||
}(core.HandleObject)); | ||
} | ||
} | ||
exports.Slot = Slot; | ||
var SlotCollection = (function (_super) { | ||
tslib_1.__extends(SlotCollection, _super); | ||
function SlotCollection(items, module, lib, classType) { | ||
if (classType === void 0) { classType = Slot; } | ||
var _this = _super.call(this, items, lib, classType) || this; | ||
_this.module = module; | ||
return _this; | ||
class SlotCollection extends core.Collection { | ||
constructor(items, module, lib, classType = Slot) { | ||
super(items, lib, classType); | ||
this.module = module; | ||
} | ||
SlotCollection.prototype.items = function (index) { | ||
items(index) { | ||
return new Slot(this.items_[index], this.module, this.lib); | ||
}; | ||
return SlotCollection; | ||
}(core.Collection)); | ||
} | ||
} | ||
exports.SlotCollection = SlotCollection; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pkcs11 = require("pkcs11js"); | ||
var TYPE_NUMBER = "number"; | ||
var TYPE_BOOL = "boolean"; | ||
var TYPE_STRING = "string"; | ||
var TYPE_BUFFER = "buffer"; | ||
var TYPE_DATE = "date"; | ||
var attribute = { | ||
const tslib_1 = require("tslib"); | ||
const pkcs11 = tslib_1.__importStar(require("pkcs11js")); | ||
const TYPE_NUMBER = "number"; | ||
const TYPE_BOOL = "boolean"; | ||
const TYPE_STRING = "string"; | ||
const TYPE_BUFFER = "buffer"; | ||
const TYPE_DATE = "date"; | ||
const attribute = { | ||
class: { v: pkcs11.CKA_CLASS, t: TYPE_NUMBER }, | ||
@@ -110,14 +111,16 @@ token: { v: pkcs11.CKA_TOKEN, t: TYPE_BOOL }, | ||
function n2i(name) { | ||
var attr = attribute[name]; | ||
if (attr !== void 0 && "v" in attr) | ||
const attr = attribute[name]; | ||
if (attr !== void 0 && "v" in attr) { | ||
return attr.v; | ||
throw new Error("Unsupported attribute name '" + name + "'. Use 'registerAttribute' to add custom attribute."); | ||
} | ||
throw new Error(`Unsupported attribute name '${name}'. Use 'registerAttribute' to add custom attribute.`); | ||
} | ||
function i2n(cka) { | ||
for (var i in attribute) { | ||
var attr = attribute[i]; | ||
if (attr && "v" in attr && attr.v === cka) | ||
for (const i in attribute) { | ||
const attr = attribute[i]; | ||
if (attr && "v" in attr && attr.v === cka) { | ||
return i; | ||
} | ||
} | ||
throw new Error("Unsupported attribute ID '" + cka + "'. Use 'registerAttribute' to add custom attribute."); | ||
throw new Error(`Unsupported attribute ID '${cka}'. Use 'registerAttribute' to add custom attribute.`); | ||
} | ||
@@ -135,33 +138,32 @@ function b2v(type, value) { | ||
default: | ||
throw new Error("Unknown type in use '" + type + "'"); | ||
throw new Error(`Unknown type in use '${type}'`); | ||
} | ||
} | ||
var Template = (function () { | ||
function Template() { | ||
} | ||
Template.toPkcs11 = function (tmpl) { | ||
var res = []; | ||
if (tmpl) | ||
for (var key in tmpl) { | ||
class Template { | ||
static toPkcs11(tmpl) { | ||
const res = []; | ||
if (tmpl) { | ||
for (const key in tmpl) { | ||
res.push({ | ||
type: n2i(key), | ||
value: tmpl[key] | ||
value: tmpl[key], | ||
}); | ||
} | ||
} | ||
return res; | ||
}; | ||
Template.fromPkcs11 = function (tmpl) { | ||
var res = {}; | ||
for (var i in tmpl) { | ||
var attr = tmpl[i]; | ||
var name_1 = i2n(attr.type); | ||
var type = attribute[name_1].t; | ||
if (type === void 0) | ||
throw new Error("Can not get type for attribute '" + name_1 + "'."); | ||
} | ||
static fromPkcs11(tmpl) { | ||
const res = {}; | ||
for (const i in tmpl) { | ||
const attr = tmpl[i]; | ||
const name = i2n(attr.type); | ||
const type = attribute[name].t; | ||
if (type === void 0) { | ||
throw new Error(`Can not get type for attribute '${name}'.`); | ||
} | ||
res[i2n(attr.type)] = b2v(type, attr.value); | ||
} | ||
return res; | ||
}; | ||
return Template; | ||
}()); | ||
} | ||
} | ||
exports.Template = Template; | ||
@@ -168,0 +170,0 @@ function registerAttribute(name, value, type) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var core = require("./core"); | ||
const tslib_1 = require("tslib"); | ||
const core = tslib_1.__importStar(require("./core")); | ||
var TokenFlag; | ||
@@ -27,15 +27,13 @@ (function (TokenFlag) { | ||
})(TokenFlag = exports.TokenFlag || (exports.TokenFlag = {})); | ||
var Token = (function (_super) { | ||
tslib_1.__extends(Token, _super); | ||
function Token(handle, lib) { | ||
var _this = _super.call(this, handle, lib) || this; | ||
_this.getInfo(); | ||
return _this; | ||
class Token extends core.HandleObject { | ||
constructor(handle, lib) { | ||
super(handle, lib); | ||
this.getInfo(); | ||
} | ||
Token.prototype.getInfo = function () { | ||
var info = this.lib.C_GetTokenInfo(this.handle); | ||
getInfo() { | ||
const info = this.lib.C_GetTokenInfo(this.handle); | ||
this.label = core.removePadding(info.label); | ||
this.manufacturerID = core.removePadding(info.manufacturerID); | ||
this.model = core.removePadding(info.model); | ||
this.serialNumber = core.removePadding(new Buffer(info.serialNumber).toString()); | ||
this.serialNumber = core.removePadding(Buffer.from(info.serialNumber).toString()); | ||
this.flags = info.flags; | ||
@@ -57,5 +55,4 @@ this.maxSessionCount = info.maxSessionCount; | ||
} | ||
}; | ||
return Token; | ||
}(core.HandleObject)); | ||
} | ||
} | ||
exports.Token = Token; |
@@ -7,2 +7,2 @@ ## Device Capabilities | ||
- [Thales nShield PCI 500 F3](capabilities/ThalesNShieldPCI500F3.md) | ||
- [Safenet Luna G5](capabilities//SafenetLunaG5.md) | ||
- [Safenet Luna 7](capabilities//SafenetLuna7.md) |
{ | ||
"name": "graphene-pk11", | ||
"version": "2.0.34", | ||
"version": "2.1.1", | ||
"description": "A simple layer for interacting with PKCS #11 / PKCS11 / CryptoKI for Node in TypeScript", | ||
"main": "./build/graphene.js", | ||
"main": "./build/index.js", | ||
"types": "index.d.ts", | ||
@@ -10,13 +10,7 @@ "scripts": { | ||
"test": "mocha", | ||
"build": "tsc", | ||
"prepare": "npm run build", | ||
"build": "npm run build:es5", | ||
"build:es5": "tsc", | ||
"build:es2015": "tsc --module es2015 --target es2015", | ||
"build:source": "tsc --sourceMap", | ||
"pub": "npm run build && npm version patch && npm publish && git push", | ||
"sync": "git ac && git pull --rebase && git push", | ||
"coverage": "npm run build:source && nyc npm test", | ||
"precoveragehtml": "npm run coverage", | ||
"coveragehtml": "nyc report -r html", | ||
"predev": "if [ ! -f coverage/index.html ]; then mkdir coverage; cp .waiting.html coverage/index.html; fi", | ||
"coverage": "nyc npm test", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls" | ||
@@ -32,12 +26,14 @@ }, | ||
"dependencies": { | ||
"int64-buffer": "^0.1.10", | ||
"pkcs11js": "^1.0.15", | ||
"tslib": "^1.9.0" | ||
"@types/mocha": "^5.2.5", | ||
"int64-buffer": "^0.99.1007", | ||
"pkcs11js": "^1.0.17", | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.5.9", | ||
"coveralls": "^3.0.0", | ||
"mocha": "^5.0.5", | ||
"nyc": "^11.6.0", | ||
"typescript": "^2.7.2" | ||
"@types/node": "^10.12.9", | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^3.1.6" | ||
}, | ||
@@ -60,3 +56,19 @@ "bugs": { | ||
"author": "PeculiarVentures", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"nyc": { | ||
"extension": [ | ||
".ts", | ||
".tsx" | ||
], | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"**/*.d.ts" | ||
], | ||
"reporter": [ | ||
"text-summary", | ||
"html" | ||
] | ||
} | ||
} |
@@ -279,3 +279,3 @@ # Graphene | ||
modulusBits: 1024, | ||
publicExponent: new Buffer([3]), | ||
publicExponent: Buffer.from([3]), | ||
token: false, | ||
@@ -346,3 +346,3 @@ verify: true, | ||
modulusBits: 1024, | ||
publicExponent: new Buffer([3]), | ||
publicExponent: Buffer.from([3]), | ||
token: false, | ||
@@ -412,3 +412,3 @@ verify: true, | ||
name: "AES_CBC_PAD", | ||
params: new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) // IV | ||
params: Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) // IV | ||
}; | ||
@@ -544,6 +544,6 @@ var MESSAGE = "Encrypted message"; | ||
token: false, | ||
id: new Buffer([1, 2, 3, 4, 5]), // Should be the same as Private/Public key has | ||
id: Buffer.from([1, 2, 3, 4, 5]), // Should be the same as Private/Public key has | ||
label: "My certificate", | ||
subject: new Buffer("3034310B300906035504...", "hex"), | ||
value: new Buffer("308203A830820290A003...", "hex"), | ||
subject: Buffer.from("3034310B300906035504...", "hex"), | ||
value: Buffer.from("308203A830820290A003...", "hex"), | ||
}; | ||
@@ -550,0 +550,0 @@ |
Sorry, the diff of this file is too big to display
249604
4
6
63
4950
+ Added@types/mocha@^5.2.5
+ Added@types/mocha@5.2.7(transitive)
+ Addedint64-buffer@0.99.1007(transitive)
- Removedint64-buffer@0.1.10(transitive)
Updatedint64-buffer@^0.99.1007
Updatedpkcs11js@^1.0.17
Updatedtslib@^1.9.3