Function fromLegacySignatureParameters

  • Migration helper: splits legacy (POST /sign-shaped) signature parameters into their signature, per-document XDC and presentation parts. null values are dropped (they mean "default" in both shapes).

    const { parameters, xdcParameters, presentation } = fromLegacySignatureParameters(legacy);
    await client.sign({ ...document, xdcParameters }, parameters, { presentation });

    Parameters

    • legacy: {
          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";
      }
      • 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}

    Returns {
        parameters: {
            checkPDFACompliance?: boolean;
            checkPDFEmbeddedAttachments?: boolean;
            container?: null | "ASiC_E";
            digestAlgorithm?: null | "SHA256" | "SHA384" | "SHA512";
            form?: null | "XAdES" | "PAdES" | "CAdES";
            infoCanonicalization?:
                | null
                | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS";
            keyInfoCanonicalization?: | null
            | "INCLUSIVE"
            | "EXCLUSIVE"
            | "INCLUSIVE_WITH_COMMENTS"
            | "EXCLUSIVE_WITH_COMMENTS"
            | "INCLUSIVE_11"
            | "INCLUSIVE_11_WITH_COMMENTS";
            packaging?: null
            | "ENVELOPED"
            | "ENVELOPING";
            profile?: null | "BASELINE_B" | "BASELINE_T";
            propertiesCanonicalization?:
                | null
                | "INCLUSIVE"
                | "EXCLUSIVE"
                | "INCLUSIVE_WITH_COMMENTS"
                | "EXCLUSIVE_WITH_COMMENTS"
                | "INCLUSIVE_11"
                | "INCLUSIVE_11_WITH_COMMENTS";
        } & { en319132?: boolean; requireQualifiedCertificate?: boolean };
        presentation?: {
            visualizationWidth?: null | "sm" | "md" | "lg" | "xl" | "xxl";
        };
        xdcParameters?: {
            autoLoadEform?: boolean;
            containerXmlns?: | null
            | "http://data.gov.sk/def/container/xmldatacontainer+xml/1.1";
            embedUsedSchemas?: boolean;
            fsFormIdentifier?: string;
            identifier?: string;
            schema?: string;
            schemaIdentifier?: string;
            schemaMimeType?: string;
            transformation?: string;
            transformationIdentifier?: string;
            transformationLanguage?: string;
            transformationMediaDestinationTypeDescription?: | null
            | "XHTML"
            | "HTML"
            | "TXT";
            transformationTargetEnvironment?: string;
        };
    }