import * as pkcs11 from "pkcs11js"; import { HandleObject } from "./core/object"; import { ITemplate } from "./template"; import type { Session } from "./session"; /** * Enumeration specifies object classes */ export declare enum ObjectClass { /** * Data object */ DATA, /** * Certificate object */ CERTIFICATE, /** * Public key object */ PUBLIC_KEY, /** * Private key object */ PRIVATE_KEY, /** * Secret key object */ SECRET_KEY, /** * Hardware feature object */ HW_FEATURE, /** * This object class was created to support the storage of certain algorithm's extended parameters */ DOMAIN_PARAMETERS, /** * Mechanism object */ MECHANISM, OTP_KEY } export type SessionObjectFactoryItemCallback = (obj: any, target: any) => any; export interface SessionObjectFactoryItem { type: any; cb?: SessionObjectFactoryItemCallback; } /** * Static class that used for session objects creation */ export declare class SessionObjectFactory { private static items; /** * Registers object constructor * @param cko Object class * @param type Object type * @param cb Callback for object creation */ static register(cko: ObjectClass, type: any, cb?: SessionObjectFactoryItemCallback): void; /** * Creates a new object from {@link SessionObject} by specified {@link ObjectClass} * @param cko Object class * @param object Session object * @return Created object */ static create(cko: ObjectClass, object: SessionObject): any; } /** * Represents a PKCS#11 session object */ export declare class SessionObject extends HandleObject { /** * PKCS#11 session */ session: Session; /** * Gets the size of an object in bytes */ get size(): number; /** * Creates an instance of {@link SessionObject} */ constructor(object: SessionObject); /** * Creates an instance of {@link SessionObject} * * @param {number} handle ID of session object * @param {Session} session PKCS#11 session * @param {pkcs11.PKCS11} lib PKCS#11 module */ constructor(handle: core.Handle, session: Session, lib: pkcs11.PKCS11); /** * Copies an object, creating a new object for the copy * * @param template Template for the new object * @returns The new instance of {@link SessionObject} */ copy(template: ITemplate): SessionObject; /** * Destroys an object */ destroy(): void; /** * Returns attribute value * @param type Attribute type * @returns Attribute value in Buffer format */ getAttribute(type: number): Buffer; /** * Returns attribute value * @param name Attribute name. See {@link ITemplate} * @returns Attribute value. Depends on the attribute name */ getAttribute(name: string): any; /** * Returns a list of attributes * @param attrs The list of attributes for receiving * @returns The list of attributes */ getAttribute(attrs: ITemplate): ITemplate; /** * Sets attribute value * @param type Attribute type * @param value Attribute value */ setAttribute(type: number, value: number | boolean | string | Buffer): void; /** * Sets attribute value * @param name Attribute name. See {@link ITemplate} * @param value Attribute value. Depends on attribute name */ setAttribute(name: string, value: any): void; /** * Sets attributes from the list of attributes * @param attrs The list of attributes */ setAttribute(attrs: ITemplate): void; /** * Alias for {@link getAttribute} */ get(type: number): Buffer; get(name: string): any; /** * Alias for {@link setAttribute} */ set(type: number, value: number | boolean | string | Buffer): void; set(name: string, value: any): void; /** * Object class (type) */ class: ObjectClass; toType(): T; protected getInfo(): void; } import * as core from "./core"; /** * Represents the collection of {@link SessionObject} */ export declare class SessionObjectCollection extends core.Collection { session: Session; /** * Creates a new instance of {@link SessionObjectCollection} * @param items The kist of {@link SessionObject} handles * @param session PKCS#11 session * @param lib PKCS#11 module */ constructor(items: core.Handle[], session: Session, lib: pkcs11.PKCS11); /** * Returns item from collection by index * @param {number} index Index of element in the collection `[0..n]` */ items(index: number): SessionObject; }