Stores information about the signing of an app item. It includes methods for creating a file with the signature’s body and attributes and for getting detailed information about a signature.

Type parameters

Hierarchy

Properties

Readonly code

code: string

App code of the URL’s target (the app’s code).

Readonly data

data: Based<Partial<EntitySign>>

Values of object’s fields.

Readonly fields

fields: Readonly<object>

Description of the object’s fields.

Readonly id

id: string

ID of the URL’s target.

Readonly namespace

namespace: string

Namespace of the URL target (the code of the workspace that the app belongs to).

Methods

createAttributesFile

  • createAttributesFile(): Promise<FileItem | undefined>
  • The method creates a file from the signed attributes of an app item.

    Returns the values of the signed attributes as a file. The example shows how to extract all attribute signatures of an app item:

    //  The signature's ID is stored in the context 
    const signId = Context.data. signId; 
    if (!signId) { 
        throw new Error('Signature ID not found'); 
    }  
    // Search for the signature by ID 
    const sign = await System.signs. entitySigns.search().where(q => q.__id.eq(signId)).first(); 
    if(!sign) {  
        throw new Error('Signature not found'); 
    } 
    // Signature files request  
    const awaitSigns = sign.signs.map(signData => signData. createAttributesFile()); 
    // Wait for the requests to finish  
    Context.data.signFiles = await Promise.all(awaitSigns); 
    

    Returns Promise<FileItem | undefined>

    File with the attributes of an app item that have been signed.

createSignFile

  • The method generates a file with a signature.

    The method returns a file with the signature’s content. It is used to get a signature’s body as a file. The example shows how to extract all file signatures of an app item:

    // The signature's ID is stored  in the context  
    const signId = Context.data.signId; 
    if (!signId) { 
         throw new Error('Signature ID not found'); 
    } 
    // Search for the signature  by ID  
    const sign = await System.signs.entitySigns.search().where(q => q. __id.eq(signId)).first(); 
    if(!sign) { 
        throw new Error('Signature not  found'); 
    } 
    // Signature files request 
    const awaitSigns = sign.signs.map( signData => signData.createSignFile()); 
    // Wait for the requests to finish  
    Context.data.signFiles = await Promise.all(awaitSigns); 
    

    Returns Promise<FileItem>

    File with the signature.

fetch

getDetails

  • The method is used to get detailed information about the signature.

    This method returns detailed information about the signature and the public key that was used to create it. The following information is extracted from the public key: attributes of the issuer and the owner, validity dates, and the public key’s name and serial number. The attributes are named according to RFC 2253, however, attributes that are not among standard CertNames fields are not encoded as hex. In the example, detailed information about a signature is extracted to save the certificate’s serial number to the process context:

    // The signature’s ID is stored in the  context 
    const signId = Context.data.signId; 
    if (!signId) { 
        throw new  Error('Signature ID not found'); 
    } 
    // Search for the signature by ID  
    const sign = await System.signs.entitySigns.search().where(q => q.__id. eq(signId)).first(); 
    if(!sign) { 
        throw new Error('Signature not  found'); 
    } 
    // Extracting the most recent signature from the history 
    const  lastSign = sign.signs[0]; 
    if (!lastSign) { 
        throw new Error('Signature  needed to extract the data'); 
    } 
    // Extract the detailed information 
    const  signDetails = await lastSign.getDetails(); 
    // Save the serial number of the  certificate to the context 
    Context.data.certificateId = signDetails. certSerialNumber; 
    

    Returns Promise<SignDetails>

    Detailed information about the signature.

normalize

  • normalize(): void
  • Delete duplicate data in arrays.

    The method deletes duplicates in fields that store arrays of links to system objects (users, files, app items, or documents). For example, you can call this method after bulk editing data within an object.

    const  app1 = await Context.data.app1.fetch();
    const app2 = await Context.data.app2 .fetch(); 
    app1.data.executors.push(app2.data.executors); 
    app1.normalize();  
    // Now we need to go over the elements in the new array 
    app1.data.executors .forEach( ... ); 
    

    Returns void

setComment

  • setComment(comment: string): Promise<void>
  • The method adds a comment to a signature.

    After signing an item using an external provider, you can save the operation’ s result as a signature draft. The comment is added as a string. In the example, the comment is saved into the draft after signing with the external provider:

    // Extracting the signature ID for the draft  
    const draftSignId = Context.data.draftSignId; 
    if (!draftSignId) { 
         throw new Error('Signature ID is required'); 
    } 
    // Searching for the  signature by ID 
    const entitySign = await System.signs.entitySigns.search(). where(f => f.__id.eq(draftSignId)).first(); 
    // Adding the content into the  signature draft 
    let comment = 'Some comment'; 
    await entitySign. setComment(comment); 
    

    Parameters

    • comment: string

      Comment upon signing or declining to sign.

    Returns Promise<void>

setStatus

  • The method sets the status of the app item signature request.

    You can use this method to change a request’s status. Pass the new status to the method.

    const entitySign = await System.signs. entitySigns.search().where(f => f.__id.eq('<some id>')).first();
    //  `getEntitySignStatus` is a function that returns the status that needs to be  assigned 
    // to the app item signature request 
    const status =  getEntitySignStatus(); 
    await entitySign.setStatus(status); 
    

    Parameters

    Returns Promise<void>

uploadSign

  • uploadSign(sign: ArrayBuffer): Promise<void>
  • The method uploads a signature’s body.

    After a third-party provider performs signing, it is possible to save the result of this operation as a signature draft. The signature is uploaded as a file generated as the result of signing. The example shows how a signature can be saved as draft after signing by the external provider:

    // Get the signature draft's ID 
    const draftSignId = Context.data .draftSignId; 
    if (!draftSignId) { 
        throw new Error('Signature ID  needed'); 
    } 
    // Search for the signature by ID 
    const entitySign = await  System.signs.entitySigns.search().where(f => f.__id.eq(draftSignId)).first();  
    // Get the signature obtained from a third-part provider; the name  `getSignContentFromExternalProvider` is given as an example 
    const sign =  await getSignContentFromExternalProvider(); 
    // Uploading the signature  content to the draft 
    await entitySign.uploadSign(sign); 
    

    Parameters

    • sign: ArrayBuffer

      Signature file content.

    Returns Promise<void>