Skip to content

Commit b356369

Browse files
authored
Merge pull request #149 from PeculiarVentures:microshine/issue148
Fix issue #148
2 parents d883dfb + e7a5d2b commit b356369

File tree

6 files changed

+27
-35
lines changed

6 files changed

+27
-35
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
},
4242
"devDependencies": {
4343
"@types/mocha": "^9.1.1",
44-
"@types/node": "^18.0.0",
44+
"@types/node": "^18.6.1",
4545
"coveralls": "^3.1.0",
4646
"mocha": "^10.0.0",
4747
"nyc": "^15.1.0",
4848
"rimraf": "^3.0.2",
49-
"ts-node": "^10.8.1",
49+
"ts-node": "^10.9.1",
5050
"tslint": "^6.1.3",
51-
"typedoc": "^0.22.17",
51+
"typedoc": "^0.23.9",
5252
"typescript": "^4.7.4"
5353
},
5454
"bugs": {

src/core/attribute.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { getAttribute } from "../template";
2+
13
/**
24
* Decorator that creates setter/getter for PKCS#11 object attributes
35
* @param name Attribute name
46
*/
57
export function attribute(name: string, defaultValue?: any) {
68
return (target: any, propertyKey: string) => {
9+
getAttribute(name); // Call getAttribute to check if attribute name is registered
10+
711
const descriptor = Object.getOwnPropertyDescriptor(target, propertyKey) || {};
812
descriptor.get = function (this: any) {
913
if (defaultValue !== undefined) {

src/objects/certs/wtls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class WtlsCertificate extends Certificate {
5252
* SHA-1 hash of the subject public key (default empty)
5353
* - Can only be empty if `CKA_URL` is empty.
5454
*/
55-
@attribute("spi")
55+
@attribute("ski")
5656
public subjectKeyIdentifier: Buffer;
5757

5858
/**

src/objects/keys/private.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class PrivateKey extends Key {
107107
* that has `CKA_TRUSTED` set to `true`. Default is `false`.
108108
* - Attribute cannot be changed once set to `true`. It becomes a read only attribute.
109109
*/
110-
@attribute("wrapTrusted", false)
110+
@attribute("wrapWithTrusted", false)
111111
public wrapTrusted: boolean;
112112

113113
/**
@@ -127,6 +127,6 @@ export class PrivateKey extends Key {
127127
* if `true`, the user has to supply the PIN for each use (sign or decrypt) with the key.
128128
* Default is `false`
129129
*/
130-
@attribute("alwaysAuthenticate", false)
130+
@attribute("alwaysAuth", false)
131131
public alwaysAuthenticate: boolean;
132132
}

src/template.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ const attribute: IAttributeItems = {
521521
/* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS,
522522
* are new for v2.10. Deprecated in v2.11 and onwards. */
523523
secondaryAuth: { v: pkcs11.CKA_SECONDARY_AUTH, t: TYPE_BOOL },
524-
authPinFlags: { v: pkcs11.CKA_AUTH_PIN_FLAGS, t: TYPE_BUFFER },
524+
authPinFlags: { v: pkcs11.CKA_AUTH_PIN_FLAGS, t: TYPE_NUMBER },
525525

526526
/* CKA_ALWAYS_AUTHENTICATE ...
527527
* CKA_UNWRAP_TEMPLATE are new for v2.20 */
528-
alwaysAuth: { v: pkcs11.CKA_ALWAYS_AUTHENTICATE, t: TYPE_BUFFER },
528+
alwaysAuth: { v: pkcs11.CKA_ALWAYS_AUTHENTICATE, t: TYPE_BOOL },
529529

530-
wrapWithTrusted: { v: pkcs11.CKA_WRAP_WITH_TRUSTED, t: TYPE_BUFFER },
530+
wrapWithTrusted: { v: pkcs11.CKA_WRAP_WITH_TRUSTED, t: TYPE_BOOL },
531531
wrapTemplate: { v: pkcs11.CKA_WRAP_TEMPLATE, t: TYPE_BUFFER },
532532
unwrapTemplate: { v: pkcs11.CKA_UNWRAP_TEMPLATE, t: TYPE_BUFFER },
533533

@@ -627,7 +627,7 @@ function b2v(type: string, value: Buffer): any {
627627
* @returns Attribute item
628628
* @throws {@link Error} if attribute name is not registered
629629
*/
630-
function getAttribute(name: string) {
630+
export function getAttribute(name: string): IAttributeItem {
631631
for (const key in attribute) {
632632
if (key === name) {
633633
return attribute[key];

yarn.lock

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@
267267
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4"
268268
integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==
269269

270-
"@types/node@^18.0.0":
271-
version "18.0.0"
272-
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a"
273-
integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==
270+
"@types/node@^18.6.1":
271+
version "18.6.1"
272+
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.6.1.tgz#828e4785ccca13f44e2fb6852ae0ef11e3e20ba5"
273+
integrity sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==
274274

275275
"@ungap/promise-all-settled@1.1.2":
276276
version "1.1.2"
@@ -879,17 +879,6 @@ glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
879879
once "^1.3.0"
880880
path-is-absolute "^1.0.0"
881881

882-
glob@^8.0.3:
883-
version "8.0.3"
884-
resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e"
885-
integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==
886-
dependencies:
887-
fs.realpath "^1.0.0"
888-
inflight "^1.0.4"
889-
inherits "2"
890-
minimatch "^5.0.1"
891-
once "^1.3.0"
892-
893882
globals@^11.1.0:
894883
version "11.12.0"
895884
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
@@ -1264,7 +1253,7 @@ minimatch@^3.0.4:
12641253
dependencies:
12651254
brace-expansion "^1.1.7"
12661255

1267-
minimatch@^5.0.1, minimatch@^5.1.0:
1256+
minimatch@^5.1.0:
12681257
version "5.1.0"
12691258
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7"
12701259
integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==
@@ -1767,10 +1756,10 @@ tough-cookie@~2.5.0:
17671756
psl "^1.1.28"
17681757
punycode "^2.1.1"
17691758

1770-
ts-node@^10.8.1:
1771-
version "10.8.1"
1772-
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.1.tgz#ea2bd3459011b52699d7e88daa55a45a1af4f066"
1773-
integrity sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g==
1759+
ts-node@^10.9.1:
1760+
version "10.9.1"
1761+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
1762+
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
17741763
dependencies:
17751764
"@cspotcode/source-map-support" "^0.8.0"
17761765
"@tsconfig/node10" "^1.0.7"
@@ -1846,12 +1835,11 @@ typedarray-to-buffer@^3.1.5:
18461835
dependencies:
18471836
is-typedarray "^1.0.0"
18481837

1849-
typedoc@^0.22.17:
1850-
version "0.22.17"
1851-
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.22.17.tgz#bc51cc95f569040112504300831cdac4f8089b7b"
1852-
integrity sha512-h6+uXHVVCPDaANzjwzdsj9aePBjZiBTpiMpBBeyh1zcN2odVsDCNajz8zyKnixF93HJeGpl34j/70yoEE5BfNg==
1838+
typedoc@^0.23.9:
1839+
version "0.23.9"
1840+
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.23.9.tgz#fd94451abd039513ab4fda58208fa0e5631e080b"
1841+
integrity sha512-rvWci2KHwteVUufZjjtIy/4PIHiE66t4VW4Ob6pezV//GHZ9Px0CHE5iq032GZzKONJWnNb+EJsrQv32INRvxA==
18531842
dependencies:
1854-
glob "^8.0.3"
18551843
lunr "^2.3.9"
18561844
marked "^4.0.16"
18571845
minimatch "^5.1.0"

0 commit comments

Comments
 (0)