graphene-pk11
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -27,2 +27,8 @@ "use strict"; | ||
class Mechanism extends core.HandleObject { | ||
constructor(type, handle, slotHandle, lib) { | ||
super(handle, lib); | ||
this.type = type; | ||
this.slotHandle = slotHandle; | ||
this.getInfo(); | ||
} | ||
get name() { | ||
@@ -80,8 +86,2 @@ return mech_enum_1.MechanismEnum[this.type] || "unknown"; | ||
} | ||
constructor(type, handle, slotHandle, lib) { | ||
super(handle, lib); | ||
this.type = type; | ||
this.slotHandle = slotHandle; | ||
this.getInfo(); | ||
} | ||
getInfo() { | ||
@@ -88,0 +88,0 @@ const info = this.lib.C_GetMechanismInfo(this.slotHandle, this.type); |
@@ -20,5 +20,2 @@ "use strict"; | ||
class SessionObject extends core.HandleObject { | ||
get size() { | ||
return this.lib.C_GetObjectSize(this.session.handle, this.handle); | ||
} | ||
constructor(handle, session, lib) { | ||
@@ -35,2 +32,5 @@ if (handle instanceof SessionObject) { | ||
} | ||
get size() { | ||
return this.lib.C_GetObjectSize(this.session.handle, this.handle); | ||
} | ||
copy(template) { | ||
@@ -37,0 +37,0 @@ const tmpl = template_1.Template.toPkcs11(template); |
@@ -136,2 +136,5 @@ "use strict"; | ||
return value; | ||
case TYPE_DATE: | ||
const date = value.toString(); | ||
return new Date(+date.slice(0, 4), +date.slice(4, 6), +date.slice(6, 8)); | ||
default: | ||
@@ -141,2 +144,10 @@ throw new Error(`Unknown type in use '${type}'`); | ||
} | ||
function getAttribute(name) { | ||
for (const key in attribute) { | ||
if (key === name) { | ||
return attribute[key]; | ||
} | ||
} | ||
throw new Error(`Unsupported attribute ID '${name}'. Use 'registerAttribute' to add custom attribute.`); | ||
} | ||
class Template { | ||
@@ -147,4 +158,12 @@ static toPkcs11(tmpl) { | ||
for (const key in tmpl) { | ||
const attr = getAttribute(key); | ||
let value = tmpl[key]; | ||
if (attr.t === TYPE_DATE) { | ||
const year = value.toLocaleDateString("en-en", { year: "numeric" }); | ||
const month = value.toLocaleDateString("en-en", { month: "2-digit" }); | ||
const day = value.toLocaleDateString("en-en", { day: "2-digit" }); | ||
value = `${year}${month}${day}`; | ||
} | ||
res.push({ | ||
type: n2i(key), | ||
type: attr.v, | ||
value: tmpl[key], | ||
@@ -151,0 +170,0 @@ }); |
{ | ||
"name": "graphene-pk11", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "A simple layer for interacting with PKCS #11 / PKCS11 / CryptoKI for Node in TypeScript", | ||
@@ -26,13 +26,13 @@ "main": "./build/index.js", | ||
"int64-buffer": "^0.99.1007", | ||
"pkcs11js": "^1.0.18", | ||
"pkcs11js": "^1.0.19", | ||
"tslib": "^1.10.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^10.14.15", | ||
"coveralls": "^3.0.6", | ||
"mocha": "^6.2.0", | ||
"nyc": "^14.1.1", | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.5.3" | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^12.12.27", | ||
"coveralls": "^3.0.9", | ||
"mocha": "^7.0.1", | ||
"nyc": "^15.0.0", | ||
"ts-node": "^8.6.2", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -39,0 +39,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250404
4966
Updatedpkcs11js@^1.0.19