Skip to content

Commit e7a5d2b

Browse files
committed
fix: incorrect names for attribute decorator calls
1 parent b8b0fce commit e7a5d2b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

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/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];

0 commit comments

Comments
 (0)