• Octosign White Label API client for the app running in the server mode.

    import { apiClient } from '@octosign/client';
    const client = apiClient();

    // Launch URL that should be used by user to launch the signer application
    console.log(client.getLaunchURL());

    await client.waitForStatus('READY');

    const content = '<?xml version="1.0"?><Document><Title>Lorem Ipsum</Title></Document>';
    console.log(await client.signLegacy({ content }));
    // => { content: '<?xml version="1.0"?><Document><Title>Lorem Ipsum</Title>...</Document>' }

    All further examples use es module and async/await, but the library can be also used as commonjs module and using promises.

    var apiClient = require('@octosign/client').apiClient;
    var client = apiClient();

    console.log(client.getLaunchURL());

    client.waitForStatus('READY')
    .then(function() {
    var content = '<?xml version="1.0"?><Document><Title>Lorem Ipsum</Title></Document>';
    return client.signLegacy({ content: content });
    })
    .then(function(signedDocument) {
    console.log(signedDocument);
    // => { content: '<?xml version="1.0"?><Document><Title>Lorem Ipsum</Title>...signature...</Document>' }
    });

    Parameters

    Returns {
        endBatch(
            batchId: string,
            abortController?: null | AbortController,
        ): Promise<{ status?: "FINISHED" | "NOT_FINISHED" }>;
        getLaunchURL(command?: "listen"): Promise<string>;
        info(): Promise<
            {
                availableDrivers?: (
                    | "eid"
                    | "cz_eid"
                    | "secure_store"
                    | "monet"
                    | "gemalto"
                    | "fake"
                    | "keystore"
                    | "custom_pkcs11"
                )[];
                features?: (
                    | "CONTENT_TIMESTAMP"
                    | "EXTERNAL_CONTENT_TIMESTAMP"
                    | "TIMESTAMP"
                    | "EN319132"
                    | "BATCH_SIGN"
                    | "PDF_A_CHECK"
                    | "PDF_EMBEDDED_ATTACHMENTS_CHECK"
                    | "SIGNING_CERTIFICATE_QUALIFIED_CHECK"
                    | "PADES"
                    | "PADES_VISUAL_SIGNATURE"
                    | "CADES"
                    | "XADES"
                    | "ASICE"
                    | "ASICE_MULTIPLE_DOCUMENTS"
                    | "ASICS"
                    | "AUTOLOAD_EFORMS"
                    | "XDC_SIGN"
                    | "XDC_VISUALIZE"
                    | "XDC_CREATE"
                    | "XDC_EMBEDDED_SIGN"
                    | "XDC_EMBEDDED_VISUALIZE"
                    | "XDC_EMBEDDED_CREATE"
                    | "SIGNATURE_VALIDATION"
                )[];
                status?: "READY";
                version?: string;
            },
        >;
        signLegacy(
            document: { content: string; filename?: string },
            signatureParameters?: {
                autoLoadEform?: boolean;
                checkPDFACompliance?: boolean;
                container?: "ASiC_E";
                containerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
                digestAlgorithm?: "SHA256" | "SHA384" | "SHA512";
                embedUsedSchemas?: boolean;
                en319132?: boolean;
                fsFormId?: string;
                identifier?: string;
                infoCanonicalization?:
                    | "INCLUSIVE"
                    | "EXCLUSIVE"
                    | "INCLUSIVE_WITH_COMMENTS"
                    | "EXCLUSIVE_WITH_COMMENTS"
                    | "INCLUSIVE_11"
                    | "INCLUSIVE_11_WITH_COMMENTS";
                keyInfoCanonicalization?: | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS";
                level?: | "BASELINE_B"
                | "BASELINE_T"
                | "XAdES_BASELINE_B"
                | "PAdES_BASELINE_B"
                | "CAdES_BASELINE_B"
                | "XAdES_BASELINE_T"
                | "PAdES_BASELINE_T"
                | "CAdES_BASELINE_T";
                packaging?: "ENVELOPED"
                | "ENVELOPING";
                propertiesCanonicalization?:
                    | "INCLUSIVE"
                    | "EXCLUSIVE"
                    | "INCLUSIVE_WITH_COMMENTS"
                    | "EXCLUSIVE_WITH_COMMENTS"
                    | "INCLUSIVE_11"
                    | "INCLUSIVE_11_WITH_COMMENTS";
                schema?: string;
                schemaIdentifier?: string;
                transformation?: string;
                transformationIdentifier?: string;
                transformationLanguage?: string;
                transformationMediaDestinationTypeDescription?: "XHTML"
                | "HTML"
                | "TXT";
                transformationTargetEnvironment?: string;
                visualizationWidth?: "sm" | "md" | "lg" | "xl" | "xxl";
            },
            payloadMimeType?: string,
            batchId?: null | string,
            abortController?: null | AbortController,
        ): Promise<DesktopSignResponseBody>;
        signV1(
            body: WithRequired,
            abortController?: null | AbortController,
        ): Promise<DesktopSignResponseBody>;
        startBatch(
            totalNumberOfDocuments: number,
            abortController?: null | AbortController,
        ): Promise<{ batchId?: string }>;
        waitForStatus(
            status: undefined | "READY",
            timeout?: number,
            delay?: number,
            abortController?: AbortController,
        ): Promise<
            {
                availableDrivers?: (
                    | "eid"
                    | "cz_eid"
                    | "secure_store"
                    | "monet"
                    | "gemalto"
                    | "fake"
                    | "keystore"
                    | "custom_pkcs11"
                )[];
                features?: (
                    | "CONTENT_TIMESTAMP"
                    | "EXTERNAL_CONTENT_TIMESTAMP"
                    | "TIMESTAMP"
                    | "EN319132"
                    | "BATCH_SIGN"
                    | "PDF_A_CHECK"
                    | "PDF_EMBEDDED_ATTACHMENTS_CHECK"
                    | "SIGNING_CERTIFICATE_QUALIFIED_CHECK"
                    | "PADES"
                    | "PADES_VISUAL_SIGNATURE"
                    | "CADES"
                    | "XADES"
                    | "ASICE"
                    | "ASICE_MULTIPLE_DOCUMENTS"
                    | "ASICS"
                    | "AUTOLOAD_EFORMS"
                    | "XDC_SIGN"
                    | "XDC_VISUALIZE"
                    | "XDC_CREATE"
                    | "XDC_EMBEDDED_SIGN"
                    | "XDC_EMBEDDED_VISUALIZE"
                    | "XDC_EMBEDDED_CREATE"
                    | "SIGNATURE_VALIDATION"
                )[];
                status?: "READY";
                version?: string;
            },
        >;
    }

    An instance of API client.

    • endBatch:function
      • Parameters

        • batchId: string
        • abortController: null | AbortController = null

        Returns Promise<{ status?: "FINISHED" | "NOT_FINISHED" }>

    • getLaunchURL:function
      • Construct custom protocol launch URI that can be opened by user to launch the application.

        import { apiClient } from '@octosign/client';
        const client = apiClient();
        console.log(client.createLaunchURI());
        // => autogram://listen/37200/https%3A%2F%2Fexample.com/3a2bca8d73c62e75177fa877de283cc0c96cdf3ba08f8eb878a96da93de3d798/260372071

        Parameters

        • command: "listen" = "listen"

        Returns Promise<string>

        URL that can be opened by the user.

    • info:function
      • Retrieve server info with its current state.

        import { apiClient } from '@octosign/client';
        const client = apiClient();
        console.log(await client.info());
        // => { version: '1.2.3', status: 'READY' }

        Returns Promise<
            {
                availableDrivers?: (
                    | "eid"
                    | "cz_eid"
                    | "secure_store"
                    | "monet"
                    | "gemalto"
                    | "fake"
                    | "keystore"
                    | "custom_pkcs11"
                )[];
                features?: (
                    | "CONTENT_TIMESTAMP"
                    | "EXTERNAL_CONTENT_TIMESTAMP"
                    | "TIMESTAMP"
                    | "EN319132"
                    | "BATCH_SIGN"
                    | "PDF_A_CHECK"
                    | "PDF_EMBEDDED_ATTACHMENTS_CHECK"
                    | "SIGNING_CERTIFICATE_QUALIFIED_CHECK"
                    | "PADES"
                    | "PADES_VISUAL_SIGNATURE"
                    | "CADES"
                    | "XADES"
                    | "ASICE"
                    | "ASICE_MULTIPLE_DOCUMENTS"
                    | "ASICS"
                    | "AUTOLOAD_EFORMS"
                    | "XDC_SIGN"
                    | "XDC_VISUALIZE"
                    | "XDC_CREATE"
                    | "XDC_EMBEDDED_SIGN"
                    | "XDC_EMBEDDED_VISUALIZE"
                    | "XDC_EMBEDDED_CREATE"
                    | "SIGNATURE_VALIDATION"
                )[];
                status?: "READY";
                version?: string;
            },
        >

        Info about the server and its current state.

    • signLegacy:function
      • Sign a document via the legacy POST /sign endpoint (all Autogram versions; one document only).

        import { apiClient } from '@octosign/client';
        const client = apiClient();

        console.log(await client.signLegacy({ content: '<?xml version="1.0"?><Document><Title>Lorem Ipsum</Title></Document>' }));
        // => { content: '...signed document...' }

        Parameters

        • document: { content: string; filename?: string }
          • content: string

            Content of the document to sign, format is dictated by payloadMimeType.

            <?xml version="1.0"?><Document><Title>Lorem Ipsum</Title></Document>
            
          • Optionalfilename?: string

            Filename of the original file to be signed. Is used to name the file inside ASiC container. If not provided with ASiC container, the file is named detached-file inside the container. If XML Document container is created, filename extension is set to .xdcf or filename is set to document.xdcf if empty.

            document.xml
            
        • signatureParameters: {
              autoLoadEform?: boolean;
              checkPDFACompliance?: boolean;
              container?: "ASiC_E";
              containerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
              digestAlgorithm?: "SHA256" | "SHA384" | "SHA512";
              embedUsedSchemas?: boolean;
              en319132?: boolean;
              fsFormId?: string;
              identifier?: string;
              infoCanonicalization?:
                  | "INCLUSIVE"
                  | "EXCLUSIVE"
                  | "INCLUSIVE_WITH_COMMENTS"
                  | "EXCLUSIVE_WITH_COMMENTS"
                  | "INCLUSIVE_11"
                  | "INCLUSIVE_11_WITH_COMMENTS";
              keyInfoCanonicalization?: | "INCLUSIVE"
              | "EXCLUSIVE"
              | "INCLUSIVE_WITH_COMMENTS"
              | "EXCLUSIVE_WITH_COMMENTS"
              | "INCLUSIVE_11"
              | "INCLUSIVE_11_WITH_COMMENTS";
              level?: | "BASELINE_B"
              | "BASELINE_T"
              | "XAdES_BASELINE_B"
              | "PAdES_BASELINE_B"
              | "CAdES_BASELINE_B"
              | "XAdES_BASELINE_T"
              | "PAdES_BASELINE_T"
              | "CAdES_BASELINE_T";
              packaging?: "ENVELOPED"
              | "ENVELOPING";
              propertiesCanonicalization?:
                  | "INCLUSIVE"
                  | "EXCLUSIVE"
                  | "INCLUSIVE_WITH_COMMENTS"
                  | "EXCLUSIVE_WITH_COMMENTS"
                  | "INCLUSIVE_11"
                  | "INCLUSIVE_11_WITH_COMMENTS";
              schema?: string;
              schemaIdentifier?: string;
              transformation?: string;
              transformationIdentifier?: string;
              transformationLanguage?: string;
              transformationMediaDestinationTypeDescription?: "XHTML"
              | "HTML"
              | "TXT";
              transformationTargetEnvironment?: string;
              visualizationWidth?: "sm" | "md" | "lg" | "xl" | "xxl";
          } = ...

          Optional signature parameters.

          • OptionalautoLoadEform?: boolean

            Try to find XSD and XSLT for a given eForm and load them automatically. Useful for visualizing and signing eForms. If true, schema, transformation, conatinerXmlns, container, packaging, and identifier parameters are ignored. If resources are not found, the response is 422. If provided document is an ASiC_E container conatining XML Datacontainer or it is an XML Datacontainer itself, XSLT found is used for visualiztion of signing document. Also, XSD and XSLT hashes are compared with hashes of XSD and XSLT found in XML Data Container EForm. If they differ, the response is 422. If the provided document is an XML document, Autogram will try to parse xmlns from root element and find resources based on its value. If successful, XML Datacontainer with xmls="http://data.gov.sk/def/container/xmldatacontainer+xml/1.1" is created, the document is validated against the XSD and visualized using the XSLT. If XSD validation fails, the response is 422. The XSLT transformation is found based on transformationLanguage (defaults to user preferred), transformationMediaDestinationTypeDescription (default XHTML, then HTML, then TXT), and transformationTargetEnvironment. If multiple transformations meet the criteria, the first one found is used.

            false
            
          • OptionalcheckPDFACompliance?: boolean

            Check for PDF/A compliance and show warning if not compliant.

            false
            
          • Optionalcontainer?: "ASiC_E"

            Optional container type that should be used to place the file with signature to. Defaults to null. Is ignored with autoLoadEform true.

            ASiC_E
            @enum {string}
          • OptionalcontainerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1"

            XML namespace for the XML Datacontainer. Specifies if xmldatacontainer should be created from XML. Doesn't create xmldatacontainer if payloadMimeType is application/vnd.gov.sk.xmldatacontainer+xml already. Accepts http://data.gov.sk/def/container/xmldatacontainer+xml/1.1 only. Defaults to null. Is ignored with autoLoadEform true.

            http://data.gov.sk/def/container/xmldatacontainer+xml/1.1
            @enum {string}
          • OptionaldigestAlgorithm?: "SHA256" | "SHA384" | "SHA512"

            Optional algorithm used to calculate digests.

            SHA256
            @enum {string}
          • OptionalembedUsedSchemas?: boolean

            When creating XML Datacontainer, parameter indicates whether to embed XSD and XML or reference them. Practically this should be only used for ORSR EForms in which case (when identifier contains "justice.gov.sk/Forms") this parameter is overridden to true.

            false
            
          • Optionalen319132?: boolean

            Optional flag to control whether the signature should be made according to ETSI EN 319132 for XAdES and ETSI EN 319122 for CAdES and PAdES.

            false
            
          • OptionalfsFormId?: string

            Specific identifier for financnasprava.sk EForms. For example, 792_772 is an identifier of "Danove priznanie - riadne".

            null
            
            792_772
            
          • Optionalidentifier?: string

            Optional identifier of the document template. Required if containerXmlns is http://data.gov.sk/def/container/xmldatacontainer+xml/1.1. Defaults to null. Is ignored with autoLoadEform true.

            https://data.gov.sk/id/egov/eform/App.GeneralAgenda/1.9
            
          • OptionalinfoCanonicalization?:
                | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS"

            Optional info canonicalization method.

            INCLUSIVE
            @enum {string}
          • OptionalkeyInfoCanonicalization?:
                | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS"

            Optional key info canonicalization method.

            INCLUSIVE
            @enum {string}
          • Optionallevel?:
                | "BASELINE_B"
                | "BASELINE_T"
                | "XAdES_BASELINE_B"
                | "PAdES_BASELINE_B"
                | "CAdES_BASELINE_B"
                | "XAdES_BASELINE_T"
                | "PAdES_BASELINE_T"
                | "CAdES_BASELINE_T"

            Signature format PAdES is usable only with documents of type application/pdf. Format XAdES is usable with XML or with any file type if using an ASiC container.

            If document is already signed (PAdES PDF or ASiC), this parameter is optional and signature format is decided based on the already signed document if empty.

            For already signed documents, BASELINE_B or BASELINE_T can be used to add another signature of the same format as the existing signature but different level.

            XAdES_BASELINE_B
            @enum {string}
          • Optionalpackaging?: "ENVELOPED" | "ENVELOPING"

            Optional form of packaging used with XML. ENVELOPED adds the signature as a child of the root element while ENVELOPING wraps the XML in a new element. Only applies to XAdES signatures. Must be ENVELOPING when used without ASiC container and with non XML documents. Is ignored with autoLoadEform true.

            ENVELOPED
            @enum {string}
          • OptionalpropertiesCanonicalization?:
                | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS"

            Optional properties canonicalization method.

            INCLUSIVE
            @enum {string}
          • Optionalschema?: string

            Optional XML schema used to validate the signing document and to compute digest used in "UsedXSDReference" in "DigestValue" attribute inside created XML Datacontainer. Format (plaintext or base64) is dictated by payloadMimeType. Is ignored with autoLoadEform true.

            <?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="Document"><xs:complexType><xs:sequence><xs:element name="Title" type="xs:string" /></xs:sequence></xs:complexType></xs:element></xs:schema>
            
          • OptionalschemaIdentifier?: string

            Optional identifier of the XML schema. The value is used in "UsedXSDReference" field inside created XML Datacontainer. If provided with autoLoadEform true, Autogram will try to find such schema. Default value is "http://schemas.gov.sk/form///form.xsd".

            http://schemas.gov.sk/form/App.GeneralAgenda/1.9/form.xsd
            
          • Optionaltransformation?: string

            Optional XML transformation used to present the signing document to user and to compute digest used in "UsedPresentationSchemaReference" in "DigestValue" attribute inside created XML Datacontainer. Format (plaintext or base64) is dictated by payloadMimeType. Is ignored with autoLoadEform true.

            <?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match = "/"><h1><xsl:value-of select="/Document/Title"/></h1></xsl:template></xsl:stylesheet>
            
          • OptionaltransformationIdentifier?: string

            Optional identifier of the XML transformation. If provided with autoLoadEform true, Autogram will try to find such transformation. Default value is "http://schemas.gov.sk/form///form.xslt".

            http://schemas.gov.sk/form/App.GeneralAgenda/1.9/form.xslt
            
          • OptionaltransformationLanguage?: string

            Optional language of the XML transformation. If autoLoadEform is true, Autogram will try to find signing XSLT with this language. Otherwise transformation must be provided. Default value is user preferred or "sk".

            sk
            
          • OptionaltransformationMediaDestinationTypeDescription?: "XHTML" | "HTML" | "TXT"

            Optional media destination type description of the XML transformation. If autoLoadEform is true, Autogram will try to find signing XSLT with this type. Otherwise transformation must be provided. Overrides value of the output method in provided or auto-loaded transformation which is used by default.

            HTML
            @enum {string}
          • OptionaltransformationTargetEnvironment?: string

            Optional target environment of the XML transformation. If autoLoadEform is true, Autogram will try to find signing XSLT with this target. Otherwise transformation must be provided. Null and not used by default.

            example-value
            
          • OptionalvisualizationWidth?: "sm" | "md" | "lg" | "xl" | "xxl"

            Optional width of the signing document visualization. Values are sm (640px), md (768px), lg (1024px), xl (1280px), xxl (1536px). The minimum visualization width is set to 640px. If the preferred visualization width is exceeds width of client's screen, the visualization width is set to the width of the client's screen.

            sm
            @enum {string}
        • payloadMimeType: string = "application/xml"

          Optional payload mime type, defaults to 'application/xml' - plaintext XML. Must reflect document content type so should be changed if content is not a plaintext XML.

        • batchId: null | string = null

          Optional batch identifier. If provided, the document is signed inside the batch.

        • abortController: null | AbortController = null

          Optional AbortController used to cancel the request.

        Returns Promise<DesktopSignResponseBody>

        Signed document.

    • signV1:function
      • Sign one or more documents via POST /api/v1/sign (Autogram >= 2.8.0).

        Multiple documents are signed together into a single ASiC_E container ("spoločná autorizácia dokumentov"). batchId may only be used with exactly one document.

        Parameters

        • body: WithRequired

          Documents (each with its own mimeType and optional xdcParameters), signature and presentation parameters.

        • abortController: null | AbortController = null

          Optional AbortController used to cancel the request.

        Returns Promise<DesktopSignResponseBody>

        Signed document (or ASiC_E container for multiple documents).

    • startBatch:function
      • Parameters

        • totalNumberOfDocuments: number
        • abortController: null | AbortController = null

        Returns Promise<{ batchId?: string }>

    • waitForStatus:function
      • Wait for server to be in the requested state.

        Repeatedly tries to get server info retrying

        import { apiClient } from '@octosign/client';
        const client = apiClient();
        await client.waitForStatus('READY');
        // => { version: '1.2.3', status: 'READY' }

        Parameters

        • status: undefined | "READY"

          Wanted status of the server.

        • timeout: number = 60

          Timeout in seconds before giving up and rejecting with error.

        • delay: number = 4

          Delay before making next attempt after failure.

        • OptionalabortController: AbortController

        Returns Promise<
            {
                availableDrivers?: (
                    | "eid"
                    | "cz_eid"
                    | "secure_store"
                    | "monet"
                    | "gemalto"
                    | "fake"
                    | "keystore"
                    | "custom_pkcs11"
                )[];
                features?: (
                    | "CONTENT_TIMESTAMP"
                    | "EXTERNAL_CONTENT_TIMESTAMP"
                    | "TIMESTAMP"
                    | "EN319132"
                    | "BATCH_SIGN"
                    | "PDF_A_CHECK"
                    | "PDF_EMBEDDED_ATTACHMENTS_CHECK"
                    | "SIGNING_CERTIFICATE_QUALIFIED_CHECK"
                    | "PADES"
                    | "PADES_VISUAL_SIGNATURE"
                    | "CADES"
                    | "XADES"
                    | "ASICE"
                    | "ASICE_MULTIPLE_DOCUMENTS"
                    | "ASICS"
                    | "AUTOLOAD_EFORMS"
                    | "XDC_SIGN"
                    | "XDC_VISUALIZE"
                    | "XDC_CREATE"
                    | "XDC_EMBEDDED_SIGN"
                    | "XDC_EMBEDDED_VISUALIZE"
                    | "XDC_EMBEDDED_CREATE"
                    | "SIGNATURE_VALIDATION"
                )[];
                status?: "READY";
                version?: string;
            },
        >

        Info about the server and its current state.