Interface AutogramVMobileIntegrationInterfaceStateful

Public interface for stateful Autogram v mobile integration/channel

interface AutogramVMobileIntegrationInterfaceStateful {
    addDocument(
        documentToSign: {
            document: { content: string; filename?: string };
            parameters?: {
                autoLoadEform?: boolean;
                checkPDFACompliance?: boolean;
                container?: "ASiC-E" | "ASiC-S";
                containerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
                digestAlgorithm?: "SHA256" | "SHA384" | "SHA512";
                embedUsedSchemas?: boolean;
                en319132?: boolean;
                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?: | "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;
            };
            payloadMimeType?: string;
        },
    ): Promise<void>;
    getPairedDevices(): Promise<
        { deviceId: string; displayName: string; platform: string }[],
    >;
    getPairingQrCodeUrl(): Promise<string>;
    getQrCodeUrl(): Promise<string>;
    init(): Promise<void>;
    loadOrRegister(regInfo: AvmRegistrationInfo): Promise<void>;
    reset(): Promise<void>;
    sendNotification(): Promise<void>;
    useRestorePoint(restorePoint: string): Promise<null | SignedObject>;
    waitForSignature(
        abortController?: AbortController,
    ): Promise<
        {
            content: string;
            filename: string;
            mimeType: string;
            signers?: { issuedBy?: string; signedBy?: string }[];
        },
    >;
}

Implemented by

Methods

  • Add a document to be signed (currently only one document is supported)

    Parameters

    • documentToSign: {
          document: { content: string; filename?: string };
          parameters?: {
              autoLoadEform?: boolean;
              checkPDFACompliance?: boolean;
              container?: "ASiC-E" | "ASiC-S";
              containerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
              digestAlgorithm?: "SHA256" | "SHA384" | "SHA512";
              embedUsedSchemas?: boolean;
              en319132?: boolean;
              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?: | "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;
          };
          payloadMimeType?: string;
      }

      Document to be signed

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

          Base64 encrypted content of the document

          ZXhhbXBsZSBzdHJpbmcgaW4gYmFzZTY0Cg==
          
        • Optionalfilename?: string

          Filename of the document. payloadMimeType must be provided if empty. Also, if payloadMimeType is empty, filename must be provided and mimetype must be understood from extension.

          sample_document.txt
          
      • Optionalparameters?: {
            autoLoadEform?: boolean;
            checkPDFACompliance?: boolean;
            container?: "ASiC-E" | "ASiC-S";
            containerXmlns?: "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
            digestAlgorithm?: "SHA256" | "SHA384" | "SHA512";
            embedUsedSchemas?: boolean;
            en319132?: boolean;
            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?: | "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;
        }
        • 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" | "ASiC-S"

          Type of Advanced Signature Container. Defaults to null - no container.

          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
          
        • 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?:
              | "XAdES_BASELINE_B"
              | "PAdES_BASELINE_B"
              | "CAdES_BASELINE_B"
              | "XAdES_BASELINE_T"
              | "PAdES_BASELINE_T"
              | "CAdES_BASELINE_T"

          Signature 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
          
      • OptionalpayloadMimeType?: string

        MIME type for document content and signature parameters XSLT transformation and XSD schema. Binary files should be encoded using base64, e.g., application/pdf;base64. Text formats like XML can be optionally encoded using base64 or supplied as plain text.

        If omitted, mimetype is decided based on document.filename and content is expected to be in Base64.

        text/plain;base64
        

    Returns Promise<void>

  • List mobile devices paired with this integration (devices that receive push notifications).

    Optional — part of the notifications capability (see getPairingQrCodeUrl).

    Returns Promise<{ deviceId: string; displayName: string; platform: string }[]>

  • Get QR code URL for pairing this integration with a mobile device.

    Optional — part of the notifications capability together with sendNotification and getPairedDevices. Channels that implement all three get the pairing UI; channels that skip them are signed by per-document QR scan only.

    Returns Promise<string>

    URL string

  • Load existing or register new integration with the Autogram v mobile server

    Parameters

    • regInfo: AvmRegistrationInfo

    Returns Promise<void>

  • Manages restore points for handling page reloads during the signing process.

    When a page gets reloaded and you have a restorePoint set up, this method will:

    1. Check if a restore point with the given identifier exists
    2. If found, check if the document is already signed
    3. If signed, restore the state and return the signed document
    4. If not signed yet, restore the state and return null (continue signing)
    5. If no restore point exists, save the current state and return null

    Parameters

    • restorePoint: string

      A unique string/hash identifier for the restore point (e.g., document hash, session ID)

    Returns Promise<null | SignedObject>

    Promise that resolves to:

    • SignedObject if a restore point was found AND the document is already signed
    • null if no restore point exists, or restore point found but document is still pending
    const channel = new AvmSimpleChannel();
    await channel.loadOrRegister();

    // Generate a unique restore point identifier (e.g., based on document hash)
    const restorePoint = `doc-${documentHash}-${signers}-${url}`;

    // Check if we're restoring from a previous session
    const signedDoc = await channel.useRestorePoint(restorePoint);

    if (signedDoc) {
    // Document was already signed during previous session
    console.log("Document already signed:", signedDoc);
    } else {
    // Either new signing or continuing from previous session
    await channel.addDocument(documentToSign);
    const qrUrl = await channel.getQrCodeUrl();
    // Show QR code to user...
    const signedDoc = await channel.waitForSignature();
    }

    Use case: User starts signing, switches to Autogram v Mobile app. Android pauses the browser (e.g., Firefox). User completes signing in AVM. When user returns to browser, the page reloads. Using restore points, the app can detect the document was already signed and complete without user interaction.

  • Waits for the document to be signed, resolving when the document is signed.

    Parameters

    • OptionalabortController: AbortController

      Optional AbortController to cancel the waiting

    Returns Promise<
        {
            content: string;
            filename: string;
            mimeType: string;
            signers?: { issuedBy?: string; signedBy?: string }[];
        },
    >

    Promise that resolves to the signed document