Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Getting error 'not_allowed' when trying to getCertificate. #67

@seweryn-piorkowski

Description

@seweryn-piorkowski

When trying to call this function I see this error.
Any ideas?

screenshot

import { hwcrypto } from '../hwcrypto/hwcrypto';

const signEstonianIdCard = (offerId: string) => {
    hwcrypto.getCertificate({ lang: 'en' }).then(function (certificate) {
      const hash = hexToPem(certificate.hex);
      hwcrypto
        .sign(certificate, { type: 'SHA-256', hex: hash }, { lang: 'en' })
        .then(
          function (signature: any) {
            request('customer', 'person')
              .get()
              .then((res) => {
                request('loans', 'sign/contract').post({
                  offerId,
                  userId: res.data.personDetails.idPerson,
                  signatureHash: signature.hex,
                  signingParty: 'applicant',
                });
              });
          },
          function (error: any) {
            console.log(`Signing failed:  ${error.message}`);
          }
        );
    });
  };

screenshot2

// Prepared function for easier exports 
export const hwcrypto = function hwcrypto() {
    "use strict";
    var _debug = function(x) {};
    _debug("hwcrypto.js activated");
    window.addEventListener = window.addEventListener || window.attachEvent;
    function hasPluginFor(mime) {
        return navigator.mimeTypes && mime in navigator.mimeTypes;
    }
[...]
fields.getCertificate = function(options) {
        if (typeof options !== "object") {
            _debug("getCertificate options parameter must be an object");
            return Promise.reject(new Error(INVALID_ARGUMENT));
        }
        if (options && !options.lang) {
            options.lang = "en";
        }
        return _autodetect().then(function(result) {
            // removed if statements because it was throwing errors on dev environment 
            return _backend.getCertificate(options).then(function(certificate) {
                if (certificate.hex && !certificate.encoded) certificate.encoded = _hex2array(certificate.hex);
                return certificate;
            });
        });
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions