### Initialize LacunaWebPKI (Complete) Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html An extended example demonstrating how to pass additional arguments to the init method, including callbacks for readiness, installation status, and default error handling. ```javascript // If you wish to pass any other argument, you must use the extended version of the method: pki.init({ ready: onWebPkiReady, notInstalled: onWebPkiNotInstalled, defaultFail: onWebPkiFail }); function onWebPkiReady() { // start using the component } // The notInstalled callback function onWebPkiNotInstalled(status, message) { alert(message + '\n\nYou will be redirected to the installation page'); pki.redirectToInstallPage(); } // The default fail callback function onWebPkiFail(ex) { alert(ex.userMessage); console.log('Web PKI error from ' + ex.origin + ': ' + ex.error + ' (' + ex.code + ')'); } ``` -------------------------------- ### Start Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.OnlineResourceXmlSignatureStarter.html Starts the XML signature process for an online resource. ```APIDOC ## Start() ### Description Starts the XML signature process for an online resource. ### Returns - **ClientSideSignatureInstructions** - Instructions for the client-side signature. ``` -------------------------------- ### Start Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the detached XML signature process and returns client-side signature instructions. ```APIDOC ## Start() ### Description Starts the detached XML signature process and returns client-side signature instructions. ### Returns #### Success Response (200) - **ClientSideSignatureInstructions** - Instructions for the client to perform the signature. ``` -------------------------------- ### StartWithWebPki Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.OnlineResourceXmlSignatureStarter.html Starts the XML signature process using Web PKI. ```APIDOC ## StartWithWebPki() ### Description Starts the XML signature process using Web PKI. ### Returns - **string** - A string representing the initiation of the Web PKI signature process. ``` -------------------------------- ### redirectToInstallPage Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki Redirects the user to the Web PKI installation page. The URL includes appropriate arguments to ensure the user is redirected back to the original page after a successful installation. ```APIDOC ## redirectToInstallPage ### Description Redirects the user to the install page with appropriate URL arguments to ensure redirection back to the original page after installation. ### Method `redirectToInstallPage(): void` ### Returns - **void** ``` -------------------------------- ### Sign Data (JSFiddle Live Example) Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html A JSFiddle live example demonstrating the operation of signing data with a selected certificate. ```javascript // Operates with selected certificate ``` -------------------------------- ### Start Signature Process with WebPki Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the signature process for a detached resource using WebPki. Overrides SignatureStarter.StartWithWebPki(). ```csharp public override string StartWithWebPki() ``` -------------------------------- ### StartAsync Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.OnlineResourceXmlSignatureStarter.html Starts the XML signature process for an online resource asynchronously. ```APIDOC ## StartAsync() ### Description Starts the XML signature process for an online resource asynchronously. ### Returns - **Task** - A task that represents the asynchronous operation, returning instructions for the client-side signature. ``` -------------------------------- ### Start Signature Process Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the signature process for a detached resource. Overrides SignatureStarter.Start(). ```csharp public override ClientSideSignatureInstructions Start() ``` -------------------------------- ### StartWithWebPki Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the detached XML signature process for use with Web PKI. ```APIDOC ## StartWithWebPki() ### Description Starts the detached XML signature process for use with Web PKI, returning a string identifier. ### Returns #### Success Response (200) - **String** - An identifier for the Web PKI signature process. ``` -------------------------------- ### Start Signature Process with WebPki Asynchronously Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the signature process for a detached resource using WebPki asynchronously. Overrides SignatureStarter.StartWithWebPkiAsync(). ```csharp public override Task StartWithWebPkiAsync() ``` -------------------------------- ### StartWithWebPkiAsync Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Asynchronously starts the detached XML signature process for use with Web PKI. ```APIDOC ## StartWithWebPkiAsync() ### Description Asynchronously starts the detached XML signature process for use with Web PKI, returning a string identifier. ### Returns #### Success Response (200) - **Task** - A task that represents the asynchronous operation, containing the identifier for the Web PKI signature process. ``` -------------------------------- ### Start Signature Process Asynchronously Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Starts the signature process for a detached resource asynchronously. Overrides SignatureStarter.StartAsync(). ```csharp public override Task StartAsync() ``` -------------------------------- ### ValidityStart Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Certificate.html Gets the date and time when the certificate becomes valid. ```csharp public DateTimeOffset ValidityStart { get; protected set; } ``` -------------------------------- ### StartAsync Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.DetachedResourceXmlSignatureStarter.html Asynchronously starts the detached XML signature process and returns client-side signature instructions. ```APIDOC ## StartAsync() ### Description Asynchronously starts the detached XML signature process and returns client-side signature instructions. ### Returns #### Success Response (200) - **Task** - A task that represents the asynchronous operation, containing the client-side signature instructions. ``` -------------------------------- ### File Validation API Request Example Source: https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core/integration/signature-sessions/file-validation.html Example of the payload sent to your custom file validation API. It includes the file's name, content type, and size. ```json { "name": "P123456.pdf", "contentType": "application/pdf", "length": 2476032 } ``` -------------------------------- ### Promise Usage Example Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/interfaces/_lacuna_web_pki_d_.promise.html Demonstrates how to use the success and fail callbacks of a Promise returned by a Web PKI asynchronous method. ```APIDOC ## Promise Usage Example ### Description This example shows how to handle the result of an asynchronous operation using the `success` and `fail` methods of the Promise object. ### Method `listCertificates().success(callback).fail(callback)` ### Endpoint N/A (This is an SDK method, not an HTTP endpoint) ### Parameters #### Success Callback - `callback` (function): A function to be executed when the promise is successfully fulfilled. It receives a single argument representing the result of the operation. #### Fail Callback - `callback` (function): A function to be executed when the promise is rejected due to an error. It receives a single argument of type `ExceptionModel`. ### Request Example ```javascript pki.listCertificates() .success(function(certs) { // Handle successful retrieval of certificates $scope.certificates = certs; }) .fail(function (ex) { // Handle errors during certificate retrieval alert('pki error from ' + ex.origin + ': ' + ex.message); console.log('pki error', ex); }); ``` ### Response #### Success Response - The type and meaning of the argument passed to the success callback depend on the method that returned the promise (e.g., string, array, object). #### Error Response - The fail callback receives an `ExceptionModel` object with `origin` and `message` properties. ``` -------------------------------- ### Start Authentication Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificateAuthentication.html Initiates an authentication process by generating and storing a new cryptographic nonce. Returns the nonce that the client must sign. ```csharp public byte[] Start() ``` -------------------------------- ### Sign Local File with CAdES (JSFiddle Example) Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html Shows how to sign a local computer file with CAdES standard using JSFiddle, saving the signed CAdES (P7S) in the same directory with a '-signed' suffix. ```javascript // JSFiddle example with local computer file and signed CAdES (P7S) saved in the same directory with suffix '-signed'. ``` -------------------------------- ### Start Authentication Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificateAuthentication.html Initiates a certificate authentication process by generating and storing a new cryptographic nonce. Returns the nonce that the client must sign. ```APIDOC ## Start() ### Description Starts an authentication process by generating and storing a new cryptographic nonce. ### Method Signature ```csharp public byte[] Start() ``` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```csharp // Example usage (conceptual) byte[] nonce = pkiCertificateAuthentication.Start(); // Client signs the nonce and sends it back along with the certificate and signature ``` ### Response #### Success Response (Byte[]) - **Byte[]** - The generated nonce (16-byte byte array) that the client must digitally sign. ``` -------------------------------- ### Get Private Key Instance from X509Certificate2 Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PrivateKey.html Creates an IPrivateKey instance from an X509Certificate2 object. ```csharp public static IPrivateKey GetInstance(X509Certificate2 x509Certificate) ``` -------------------------------- ### Sign Data with CAdES (JSFiddle Example) Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html Demonstrates signing file content using CAdES standard via JSFiddle, returning the signed CAdES (P7S) result to JavaScript. ```javascript // JSFiddle example with the to sign file content passed from JavasSript and the signed CAdES (P7S) result returned to JavasSript. ``` -------------------------------- ### Start Authentication Asynchronously Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificateAuthentication.html Asynchronously initiates an authentication process, generating and storing a new cryptographic nonce. Returns the nonce that the client must sign. ```csharp public Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)) ``` -------------------------------- ### Get Private Key Instance from AsymmetricAlgorithm Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PrivateKey.html Creates a PrivateKey instance from an existing AsymmetricAlgorithm object. ```csharp public static PrivateKey GetInstance(AsymmetricAlgorithm underlyingPrivateKey) ``` -------------------------------- ### Start Authentication Asynchronously Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificateAuthentication.html Asynchronously initiates a certificate authentication process by generating and storing a new cryptographic nonce. Returns a task that resolves to the nonce. ```APIDOC ## StartAsync(CancellationToken) ### Description Asynchronously starts an authentication process by generating and storing a new cryptographic nonce. ### Method Signature ```csharp public Task StartAsync(CancellationToken cancellationToken = default(CancellationToken)) ``` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None #### Method Parameters - **cancellationToken** (CancellationToken) - Optional - A token to observe for cancellation requests. ### Request Example ```csharp // Example usage (conceptual) byte[] nonce = await pkiCertificateAuthentication.StartAsync(); // Client signs the nonce and sends it back along with the certificate and signature ``` ### Response #### Success Response (Task) - **Task** - A task that resolves to the generated nonce (16-byte byte array) that the client must digitally sign. ``` -------------------------------- ### Document Ready Event Handlers Source: https://docs.lacunasoftware.com/pt-br/articles/web-pki/full-samples.html Initializes the UI by setting up click handlers for buttons and starting the initial block UI. Executes when the DOM is fully loaded. ```javascript $(function() { $('#refreshButton').click(refresh); $('#signFileButton').click(signFile); start(); }); ``` -------------------------------- ### Instantiate SelfSignedPKCertificateGenerator Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Issuer.SelfSignedPKCertificateGenerator.html Creates a new instance of the SelfSignedPKCertificateGenerator class. No specific setup is required before instantiation. ```csharp public SelfSignedPKCertificateGenerator() ``` -------------------------------- ### Configurar Repositório e Instalar ASP.NET Core Runtime 6.0 no Ubuntu 20.04 LTS Source: https://docs.lacunasoftware.com/pt-br/articles/amplia/on-premises/linux/install-ubuntu.html Configura o repositório de pacotes da Microsoft e instala o ASP.NET Core Runtime 6.0 no Ubuntu 20.04 LTS. Este procedimento deve ser feito apenas uma vez por máquina. ```bash curl -O https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb ``` ```bash apt-get update apt-get install aspnetcore-runtime-6.0 ``` -------------------------------- ### Testar Instalação do .NET Runtime Source: https://docs.lacunasoftware.com/pt-br/articles/psc/on-premises/linux/install-rocky.html Verifica se o ASP.NET Core Runtime e o .NET Core App foram instalados corretamente. A saída deve listar as versões instaladas. ```bash dotnet --list-runtimes ``` -------------------------------- ### Configurar Repositório e Instalar ASP.NET Core Runtime 6.0 no Ubuntu 16.04 LTS Source: https://docs.lacunasoftware.com/pt-br/articles/amplia/on-premises/linux/install-ubuntu.html Configura o repositório de pacotes da Microsoft e instala o ASP.NET Core Runtime 6.0 no Ubuntu 16.04 LTS. Este procedimento deve ser feito apenas uma vez por máquina. ```bash curl -O https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb ``` ```bash apt-get update apt-get install aspnetcore-runtime-6.0 ``` -------------------------------- ### Testar Instalação do .NET Core Runtime Source: https://docs.lacunasoftware.com/pt-br/articles/amplia/on-premises/linux/install-ubuntu.html Verifica se o ASP.NET Core Runtime 6.0 foi instalado corretamente listando os runtimes disponíveis no sistema. ```bash dotnet --list-runtimes ``` -------------------------------- ### Configurar Repositório e Instalar ASP.NET Core Runtime 6.0 no Ubuntu 18.04 LTS Source: https://docs.lacunasoftware.com/pt-br/articles/amplia/on-premises/linux/install-ubuntu.html Configura o repositório de pacotes da Microsoft e instala o ASP.NET Core Runtime 6.0 no Ubuntu 18.04 LTS. Este procedimento deve ser feito apenas uma vez por máquina. ```bash curl -O https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb ``` ```bash apt-get update apt-get install aspnetcore-runtime-6.0 ``` -------------------------------- ### Instalar ASP.NET Core Runtime 6.0 Source: https://docs.lacunasoftware.com/pt-br/articles/psc/on-premises/linux/install-rocky.html Instala o pacote do ASP.NET Core runtime necessário para o Lacuna PSC. Certifique-se de estar autenticado como root ou use sudo. ```bash yum install aspnetcore-runtime-6.0 ``` -------------------------------- ### File Validation API Accept Response Source: https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core/integration/signature-sessions/file-validation.html Example of a successful response from your file validation API, indicating that the file should be accepted. ```json { "accept": true, "rejectReason": null } ``` -------------------------------- ### Expected Rest PKI System Info XML Source: https://docs.lacunasoftware.com/pt-br/articles/rest-pki/troubleshoot/could-not-get-pending-sig.html This is an example of the expected XML response when successfully accessing the Rest PKI System Info endpoint. It confirms the Rest PKI instance is reachable and functioning. ```xml Lacuna Rest PKI 1.13.1 ``` -------------------------------- ### Listar usuários Source: https://docs.lacunasoftware.com/pt-br/articles/signer/on-premises/administration.html Para listar os usuários cadastrados no sistema, obtendo assim seus dados e permissões, utilize a chamada `GET /api/users`. ```APIDOC ## GET /api/users ### Description Lista os usuários cadastrados no sistema, retornando seus dados e permissões. ### Method GET ### Endpoint /api/users ### Parameters #### Query Parameters - **q** (string) - Opcional - Permite filtrar os usuários retornados por nome, CPF ou e-mail. ### Response #### Success Response (200) - **items** (array) - Lista de usuários. - **identifier** (string) - Identificador único do usuário. - **phone** (string) - Telefone do usuário. - **id** (string) - ID do usuário. - **subject** (string) - Subject do usuário. - **name** (string) - Nome do usuário. - **emailAddress** (string) - Endereço de e-mail do usuário. - **parentId** (string) - ID do pai do usuário. - **rootRoles** (array) - Lista de roles raiz do usuário. - **parentRootRoles** (array) - Lista de parent root roles do usuário. - **subscriptions** (array) - Lista de assinaturas do usuário. - **agentId** (string) - ID do agente da assinatura. - **subscriptionId** (string) - ID da assinatura. - **roles** (array) - Lista de roles da assinatura. - **parentRoles** (array) - Lista de parent roles da assinatura. - **totalCount** (integer) - Número total de usuários. - **nextCursor** (string) - Cursor para a próxima página de resultados. ### Response Example ```json { "items": [ { "identifier": "99999999999", "phone": null, "id": "446e14b9-a661-446a-bb52-66b6c9f1ade9", "subject": "17bb43bd-1dac-46ce-95d2-62007bee2aea", "name": "User One", "emailAddress": "User.One@mailinator.com", "parentId": null, "rootRoles": [], "parentRootRoles": null, "subscriptions": [ { "agentId": "446e14b9-a661-446a-bb52-66b6c9f1ade9", "subscriptionId": "28dd8bc0-ef7a-44e4-b2f8-08da757b7cf1", "roles": [ "Admin", "Manager", "Basic" ], "parentRoles": null } ] }, { "identifier": "11096802449", "phone": "+55 61 99999-9999", "id": "7b06a7ed-43fc-45df-96f8-cb29f4778e22", "subject": "ee72e66e-c150-47c3-a8fd-d4d0c6e12ef5", "name": "User Two", "emailAddress": "user.two@mailinator.com", "parentId": null, "rootRoles": [], "parentRootRoles": null, "subscriptions": [ { "agentId": "7b06a7ed-43fc-45df-96f8-cb29f4778e22", "subscriptionId": "7289e60f-0c1f-4a3d-4b81-08da718c9ef3", "roles": [ "Admin", "Manager", "Basic" ], "parentRoles": null } ] } ], "totalCount": 2, "nextCursor": null } ``` ``` -------------------------------- ### Instalar ASP.NET Core Runtime 6.0 no Ubuntu 22.04 LTS Source: https://docs.lacunasoftware.com/pt-br/articles/amplia/on-premises/linux/install-ubuntu.html Instala o ASP.NET Core Runtime 6.0 no Ubuntu 22.04 LTS. Execute este comando após atualizar a lista de pacotes. ```bash apt-get update apt-get install aspnetcore-runtime-6.0 ``` -------------------------------- ### PdfMarkElement.Rotation Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.PdfMarkElement.html Gets or sets the rotation of the PDF mark element. ```csharp public int Rotation { get; set; } ``` -------------------------------- ### Initialize LacunaWebPKI (Simple) Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html The simplest way to initialize the component. Use this when you don't need to register a default error callback or handle custom installation/outdated scenarios. ```javascript // This is the simplest way to call the method, in case you don't wish to register a default error callback nor // define a custom behavior for when the component is not installed/outdated. pki.init({ ready: onWebPkiReady }); // The ready callback receives no arguments function onWebPkiReady() { // start using the component } ``` -------------------------------- ### PdfMarkElement.Opacity Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.PdfMarkElement.html Gets or sets the opacity of the PDF mark element. ```csharp public double Opacity { get; set; } ``` -------------------------------- ### PdfMarkElement.ElementType Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.PdfMarkElement.html Gets or sets the type of the PDF mark element. ```csharp public PdfMarkElementType ElementType { get; set; } ``` -------------------------------- ### PrivateKey Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Issuer.SelfSignedPKCertificateGenerator.html Gets or sets the private key for the self-signed certificate. ```APIDOC ## PrivateKey ### Description Gets or sets the private key for the self-signed certificate. ### Property Type PrivateKey ``` -------------------------------- ### ValidityEnd Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Certificate.html Gets the date and time when the certificate becomes invalid. ```csharp public DateTimeOffset ValidityEnd { get; protected set; } ``` -------------------------------- ### PdfMarkElement.RelativeContainer Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.PdfMarkElement.html Gets or sets the relative container for the PDF mark element. ```csharp public PadesVisualRectangle RelativeContainer { get; set; } ``` -------------------------------- ### SignatureTimestamp Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for signature timestamps. ```csharp public ValidationRequirementLevels SignatureTimestamp { get; set; } ``` -------------------------------- ### RevocationValues Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for revocation values. ```csharp public ValidationRequirementLevels RevocationValues { get; set; } ``` -------------------------------- ### CertificateValues Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for certificate values. ```csharp public ValidationRequirementLevels CertificateValues { get; set; } ``` -------------------------------- ### ArchiveTimestamp Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for archive timestamps. ```csharp public ValidationRequirementLevels ArchiveTimestamp { get; set; } ``` -------------------------------- ### Uri Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.TimestampRequester.html Gets the Uniform Resource Identifier (URI) of the timestamping authority. ```csharp public Uri Uri { get; } ``` -------------------------------- ### init Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki Initializes the instance of the LacunaWebPKI object. This method must be called before calling any other methods. ```APIDOC ## init ### Description Initializes the instance of the LacunaWebPKI object. This method must be called before calling any other methods. ### Method init(args: object): Promise ### Parameters #### args: object - **Optional angularScope?**: Object - If your webpage uses AngularJS, you can pass here a reference to your $scope, which will then be used to call the callback functions properly, relieving you of doing a `$scope.$apply(function() { ... });` on every callback. The calls are actually wrapped around a "safe $apply", as described in coderwall. - **Optional brand?**: string - The brand name for customized install page, if license covered. - **Optional defaultFail?**: FailCallback - The default callback to be called when an error occurrs (please refer to examples below for the exact function signature). - **Optional license?**: string | Object - The license for the component, if not already set when instantiating the object. - **Optional mobileIntegrationMode?**: MobileIntegrationModes - The mobile integration mode. Default is LacunaWebPKI.MobileIntegrationModes.AppIntegration. - **Optional ngZone?**: Object - If your webpage uses Angular2+ technologies, you can pass a NgZone reference, so the page can properly detect elements changes on the callback functions. - **Optional notInstalled?**: function - A function to be called if the component's installation is not OK (component not installed, outdated or user is using an unsupported browser). If no callback is given, the user is automatically redirected to the installation website and will be redirected back once the installation is completed. If you do pass a callback to override the default behavior, use the redirectToInstallPage method to redirect the user to the installation page whenever you think it's convenient. * (status: InstallationStates, message: string): any - **Optional ready?**: function - A function to be called when the component is ready to be used. The function receives no arguments. * (): any - **Optional requiredApiVersion?**: ApiVersions - If you intend to use a specifc features set, pass the equivalent API version required parameter, so you can ensure that the users will have the minimum components required versions and will not force any unecessary update. See the API changelog for more information. - **Optional restPkiUrl?**: string - The _on premises_ Rest PKI URL. For _on premises_ Rest PKI clients integration only. - **Optional useDomainNativePool?**: boolean - Whether or not to share and persiste the native app instances per hostname. Default is one native app instance per page. ### Returns Promise ### Request Example ```javascript // This is the simplest way to call the method, in case you don't wish to register a default error callback nor // define a custom behavior for when the component is not installed/outdated. pki.init({ ready: onWebPkiReady }); // The ready callback receives no arguments function onWebPkiReady() { // start using the component } ``` ### Complete Example ```javascript // If you wish to pass any other argument, you must use the extended version of the method: pki.init({ ready: onWebPkiReady, notInstalled: onWebPkiNotInstalled, defaultFail: onWebPkiFail }); function onWebPkiReady() { // start using the component } // The notInstalled callback function onWebPkiNotInstalled(status, message) { alert(message + '\n\nYou will be redirected to the installation page'); pki.redirectToInstallPage(); } // The default fail callback function onWebPkiFail(ex) { alert(ex.userMessage); console.log('Web PKI error from ' + ex.origin + ': ' + ex.error + ' (' + ex.code + ')'); } ``` ``` -------------------------------- ### init Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html Initializes the instance of the LacunaWebPKI object. This method must be called before calling any other methods. ```APIDOC ## init ### Description Initializes the instance of the LacunaWebPKI object. This method must be called before calling any other methods. ### Method `init(args: object): Promise` ### Parameters #### args: object - **Optional angularScope?**: Object - If your webpage uses AngularJS, you can pass here a reference to your $scope, which will then be used to call the callback functions properly, relieving you of doing a `$scope.$apply(function() { ... });` on every callback. The calls are actually wrapped around a "safe $apply", as described in coderwall. - **Optional brand?**: string - The brand name for customized install page, if license covered. - **Optional defaultFail?**: FailCallback - The default callback to be called when an error occurrs (please refer to examples below for the exact function signature). - **Optional license?**: string | Object - The license for the component, if not already set when instantiating the object. - **Optional mobileIntegrationMode?**: MobileIntegrationModes - The mobile integration mode. Default is LacunaWebPKI.MobileIntegrationModes.AppIntegration. - **Optional ngZone?**: Object - If your webpage uses Angular2+ technologies, you can pass a NgZone reference, so the page can properly detect elements changes on the callback functions. - **Optional notInstalled?**: function - A function to be called if the component's installation is not OK (component not installed, outdated or user is using an unsupported browser). If no callback is given, the user is automatically redirected to the installation website and will be redirected back once the installation is completed. If you do pass a callback to override the default behavior, use the redirectToInstallPage method to redirect the user to the installation page whenever you think it's convenient. - Parameters: - **status**: InstallationStates - **message**: string - **Optional ready?**: function - A function to be called when the component is ready to be used. The function receives no arguments. - **Optional requiredApiVersion?**: ApiVersions - If you intend to use a specifc features set, pass the equivalent API version required parameter, so you can ensure that the users will have the minimum components required versions and will not force any unecessary update. See the API changelog for more information. - **Optional restPkiUrl?**: string - The _on premises_ Rest PKI URL. For _on premises_ Rest PKI clients integration only. - **Optional useDomainNativePool?**: boolean - Whether or not to share and persiste the native app instances per hostname. Default is one native app instance per page. ### Returns `Promise` ### Request Example Simple `ready` example ```javascript // This is the simplest way to call the method, in case you don't wish to register a default error callback nor // define a custom behavior for when the component is not installed/outdated. pki.init({ ready: onWebPkiReady }); // The ready callback receives no arguments function onWebPkiReady() { // start using the component } ``` Complete example ```javascript // If you wish to pass any other argument, you must use the extended version of the method: pki.init({ ready: onWebPkiReady, notInstalled: onWebPkiNotInstalled, defaultFail: onWebPkiFail }); function onWebPkiReady() { // start using the component } // The notInstalled callback function onWebPkiNotInstalled(status, message) { alert(message + '\n\nYou will be redirected to the installation page'); pki.redirectToInstallPage(); } // The default fail callback function onWebPkiFail(ex) { alert(ex.userMessage); console.log('Web PKI error from ' + ex.origin + ': ' + ex.error + ' (' + ex.code + ')'); } ``` ``` -------------------------------- ### DocumentTimestamp Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Pades.SignerSpecs.AttributeValidationSpec.html Gets or sets the validation requirement level for the document timestamp. ```csharp public ValidationRequirementLevels DocumentTimestamp { get; set; } ``` -------------------------------- ### Full File Signing Workflow Source: https://docs.lacunasoftware.com/pt-br/articles/web-pki/full-samples.html This snippet demonstrates the complete process of signing a dummy file using Web PKI. It includes all steps from initiating the signature to downloading the signed file. Requires AngularJS, blockUI, and $http services. ```javascript // This function is called when the user clicks the button "Sign Dummy File" $scope.signFile = function () { blockUI.start('Signing ... (step 1/4)'); // The first thing we'll do is read the certificate encoding log('Reading certificate ...'); pki.readCertificate($scope.selectedCertificate.thumbprint).success(onReadCertificateCompleted); }; // This function is the callback for when the readCertificate operation is completed var onReadCertificateCompleted = function (certContent) { blockUI.message('Signing ... (step 2/4)'); // Now that we have acquired the certificate's encoding, we'll send that to the // server using Ajax log('Certificate binary encoding read, sending to server ...'); $http.post('https://webpki.lacunasoftware.com/api/Signature/Start', { certificate: certContent }).success(onSignatureStartCompleted); }; // This function is the callback for when the server replies back with the "to-sign-bytes" // and digest algorithm oid. var onSignatureStartCompleted = function (response) { log('Received response from server with bytes to sign and digest algorithm'); log('toSign: ' + response.toSign); log('digestAlgorithmOid: ' + response.digestAlgorithmOid); log('Signing ...'); blockUI.message('Signing ... (step 3/4)'); signatureProcessId = response.processId; // Now that we have the bytes to be signed and the OID of the digest algorithm that // should be used during the signature, we call signData pki.signData({ thumbprint: $scope.selectedCertificate.thumbprint, data: response.toSign, digestAlgorithm: response.digestAlgorithmOid }).success(onSignDataCompleted); }; // This function is the callback for when the signData operation is completed var onSignDataCompleted = function (signature) { blockUI.message('Signing ... (step 4/4)'); log('Signature completed, submitting to server ...'); // We send the signature result back to the server, which will then use // its server-side SDK to assemble the signed PDF file $http.post('https://webpki.lacunasoftware.com/api/Signature/Complete', { processId: signatureProcessId, signature: signature }).success(onSignatureCompleteCompleted); }; // This function is the callback for when the server replies back signalling that // the signature process is completed and we may download the signed PDF file. var onSignatureCompleteCompleted = function () { log('Process completed!'); blockUI.stop(); showModal('Message', 'Dummy file signed successfully. Click OK to download the signed file.', function (modalInstance) { document.location.href = 'https://webpki.lacunasoftware.com/api/Signature/' + signatureProcessId; modalInstance.close(); }); }; // Auxiliary functions var log = function (message) { if (window.console) { window.console.log(message); } }; var showModal = function (title, message, okCallback) { $modal.open({ template: '', controller: 'ModalController', resolve: { message: function () { return message; }, title: function () { return title; }, okCallback: function () { return okCallback; } } }); }; // Once our controller is ready, we call the start method start(); }); app.controller('ModalController', function ($scope, $modalInstance, title, message, okCallback) { $scope.title = title; $scope.message = message; $scope.OK = function() { if (okCallback) { okCallback($modalInstance); } else { $modalInstance.close(); } }; }); ``` -------------------------------- ### SigningCertificateProperty Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for the signing certificate property. ```csharp public ValidationRequirementLevels SigningCertificateProperty { get; set; } ``` -------------------------------- ### SigAndRefsTimestamp Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for signature and references timestamps. ```csharp public ValidationRequirementLevels SigAndRefsTimestamp { get; set; } ``` -------------------------------- ### PdfMarkQRCodeElement Constructor (With Container and Data) Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.RestPki.Client.PdfMarkQRCodeElement.html Initializes a new instance of the PdfMarkQRCodeElement class with a specified relative container and QR code data. Use this constructor to immediately define the QR code's position and content. ```csharp public PdfMarkQRCodeElement(PadesVisualRectangle relativeContainer, string qrCodeData) ``` -------------------------------- ### RequiredXmlTransformations Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets a list of required XML transformations to apply during validation. ```csharp public List RequiredXmlTransformations { get; set; } ``` -------------------------------- ### Instantiate CadesAcceptablePoliciesCatalog with explicit policies Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Cades.CadesAcceptablePoliciesCatalog.html Initializes a catalog with a list of explicit CAdES policies. An optional list of policies can be provided. ```csharp public CadesAcceptablePoliciesCatalog(IEnumerable policies = null) ``` -------------------------------- ### OptionalXmlTransformations Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets a list of optional XML transformations to apply during validation. ```csharp public List OptionalXmlTransformations { get; set; } ``` -------------------------------- ### CompleteRevocationReferences Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for complete revocation references. ```csharp public ValidationRequirementLevels CompleteRevocationReferences { get; set; } ``` -------------------------------- ### Instantiate LacunaWebPKI with Binary License Source: https://docs.lacunasoftware.com/content/typedocs/web-pki/classes/_lacuna_web_pki_d_.lacunawebpki.html Use this snippet to instantiate the LacunaWebPKI object with a binary license. This format is preferred for hiding license details like expiration dates and allowed domains. ```javascript var pki = new LacunaWebPKI('ASYAanNmaWRkbGUubmV0LHdlYnBraS5sYWN1bmFzb2Z0d2FyZS5jb20AAAABClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ=='); ``` -------------------------------- ### CompleteCertificateReferences Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.XmlPolicySpec.ValidationSpec.html Gets or sets the validation requirement level for complete certificate references. ```csharp public ValidationRequirementLevels CompleteCertificateReferences { get; set; } ``` -------------------------------- ### FullXmlSigner Constructor Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.FullXmlSigner.html Initializes a new instance of the FullXmlSigner class. ```APIDOC ## FullXmlSigner() ### Description Initializes a new instance of the FullXmlSigner class. ### Syntax ```csharp public FullXmlSigner() ``` ``` -------------------------------- ### SubjectName Property Declaration Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificate.html Gets or sets the subject name of the certificate. The type is Name. ```csharp public Name SubjectName { get; protected set; } ``` -------------------------------- ### PrivateKey.GetInstance Methods Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PrivateKey.html Static methods to obtain a PrivateKey instance from an existing asymmetric algorithm or an X.509 certificate. ```APIDOC ## PrivateKey.GetInstance(AsymmetricAlgorithm) ### Description Gets an instance of PrivateKey from an asymmetric algorithm. ### Method ``` public static PrivateKey GetInstance(AsymmetricAlgorithm underlyingPrivateKey) ``` ### Parameters #### Path Parameters - **underlyingPrivateKey** (AsymmetricAlgorithm) - Description: The underlying asymmetric algorithm. ### Returns - **PrivateKey** - An instance of PrivateKey. ## PrivateKey.GetInstance(X509Certificate2) ### Description Gets an instance of IPrivateKey from an X.509 certificate. ### Method ``` public static IPrivateKey GetInstance(X509Certificate2 x509Certificate) ``` ### Parameters #### Path Parameters - **x509Certificate** (X509Certificate2) - Description: The X.509 certificate. ### Returns - **IPrivateKey** - An instance of IPrivateKey. ``` -------------------------------- ### IssuerName Property Declaration Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.PKCertificate.html Gets or sets the issuer name of the certificate. The type is Name. ```csharp public Name IssuerName { get; protected set; } ``` -------------------------------- ### SigningCertificateAttribute Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Pades.SignerSpecs.AttributeValidationSpec.html Gets or sets the validation requirement level for the signing certificate attribute. ```csharp public ValidationRequirementLevels SigningCertificateAttribute { get; set; } ``` -------------------------------- ### Sign and Verify Hash with Private Key Source: https://docs.lacunasoftware.com/pt-br/articles/pki-sdk/certificates/certs-with-key.html Demonstrates signing a pre-computed hash and verifying it using a certificate's private key. Requires a PKCertificateWithKey object and specifies the digest algorithm. ```csharp PKCertificateWithKey certWithKey = ... // Definindo algoritmo de digest var digestAlgorithm = DigestAlgorithm.SHA256; // Computando hash a ser assinado var toSignHash = digestAlgorithm.ComputeHash(System.Text.Encoding.ASCII.GetBytes("hello pki")); // Assinando com certificado var signature = certWithKey.SignHash(digestAlgorithm, toSignHash); // Verificando assinatura Console.WriteLine(certWithKey.VerifyHash(digestAlgorithm, toSignHash, signature)); ``` -------------------------------- ### SignaturePolicyIdentifier Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Pades.SignerSpecs.AttributeValidationSpec.html Gets or sets the validation requirement level for the signature policy identifier. ```csharp public ValidationRequirementLevels SignaturePolicyIdentifier { get; set; } ``` -------------------------------- ### Sign and Verify Data with Private Key Source: https://docs.lacunasoftware.com/pt-br/articles/pki-sdk/certificates/certs-with-key.html Demonstrates signing arbitrary data and verifying the signature using a certificate's private key. Requires a PKCertificateWithKey object and specifies the digest algorithm. ```csharp PKCertificateWithKey certWithKey = ... // Definindo algoritmo de digest var digestAlgorithm = DigestAlgorithm.SHA256; // Definindo bytes a serem assinados var toSign = System.Text.Encoding.ASCII.GetBytes("hello pki"); // Assinando com certificado var signature = certWithKey.SignData(digestAlgorithm, toSign); // Verificando assinatura Console.WriteLine(certWithKey.VerifyData(digestAlgorithm, toSign, signature)); ``` -------------------------------- ### CmsSigningTime Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Pades.SignerSpecs.AttributeValidationSpec.html Gets or sets the validation requirement level for the CMS signing time. ```csharp public ValidationRequirementLevels CmsSigningTime { get; set; } ``` -------------------------------- ### CmsSignatureTimestamp Property Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Pades.SignerSpecs.AttributeValidationSpec.html Gets or sets the validation requirement level for the CMS signature timestamp. ```csharp public ValidationRequirementLevels CmsSignatureTimestamp { get; set; } ``` -------------------------------- ### FullXmlSigner Constructor Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Xml.FullXmlSigner.html Initializes a new instance of the FullXmlSigner class. ```csharp public FullXmlSigner() ``` -------------------------------- ### Create Organization Source: https://docs.lacunasoftware.com/pt-br/articles/signer/on-premises/administration.html Creates a new organization with the specified name and identifier. ```bash POST /api/admin/organizations ``` ```json { "name": "newOrg", "identifier": "85932577000194" } ``` -------------------------------- ### GetCertificateChain Method Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.Certificate.html Retrieves the complete certificate chain, starting from the current certificate up to the root certificate. ```csharp public List GetCertificateChain() ``` -------------------------------- ### SetValidity(DateTimeOffset, DateTimeOffset) Source: https://docs.lacunasoftware.com/pt-br/api/Lacuna.Pki.AttributeCertificateGenerator.html Sets the validity period (start and end dates) for the attribute certificate. ```APIDOC ## SetValidity(DateTimeOffset, DateTimeOffset) ### Description Sets the validity period (start and end dates) for the attribute certificate. ### Method public void SetValidity(DateTimeOffset start, DateTimeOffset end) ### Parameters #### Path Parameters - **start** (DateTimeOffset) - Description: The start date and time of the certificate's validity. - **end** (DateTimeOffset) - Description: The end date and time of the certificate's validity. ``` -------------------------------- ### Configurar Representação Visual Manual Source: https://docs.lacunasoftware.com/pt-br/articles/pki-express/python/visual-rep/index.html Define a inserção da representação visual na última página de um documento PDF com dimensões e margens específicas. Use para posicionamento preciso. ```python signer = PadesSigner() ... visual = { 'position': { 'pageNumber': -1, # Define inserção na última página do documento 'manual': { 'width': 7, # Largura = 7cm 'height': 3, # Altura = 3cm 'left': 2.50, # Distância da margem esquerda = 2.50cm 'bottom': 2.50 # Distância da margem inferior = 2.50cm } }, 'text': {...}, 'image': {...} } signer.set_visual_representation(visual) ``` -------------------------------- ### Listar organizações Source: https://docs.lacunasoftware.com/pt-br/articles/signer/on-premises/administration.html Para listar as organizações cadastradas no sistema, utilize a chamada `GET /api/admin/organizations`. ```APIDOC ## GET /api/admin/organizations ### Description Lista as organizações cadastradas no sistema. ### Method GET ### Endpoint /api/admin/organizations ### Parameters #### Query Parameters - **limit** (int) - Opcional - Quantidade de itens por página. - **offset** (int) - Opcional - Número da página. - **personal** (boolean) - Opcional - Indica se deve retornar organizações pessoais. - **q** (string) - Opcional - Permite filtrar pelo nome da organização. ### Response #### Success Response (200) - **items** (array) - Lista de organizações. - **id** (string) - ID da organização. - **name** (string) - Nome da organização. - **identifier** (string) - Identificador da organização. - **owner** (object) - Informações do proprietário da organização. - **id** (string) - ID do proprietário. - **name** (string) - Nome do proprietário. - **totalCount** (integer) - Número total de organizações. - **nextCursor** (string) - Cursor para a próxima página de resultados. ### Response Example ```json { "items": [ { "id": "5aaa9032-1ad0-4c63-3c73-08d9d088eeac", "name": null, "identifier": null, "owner": { "id": "6f9d67cc-5cea-4672-b09e-ac04ed2e348f", "name": "Novo User" } } ], "totalCount": 17, "nextCursor": null } ``` ```