'use strict';

var vc_crypto_constants = require('./constants.cjs');
var vc_crypto_Ed25519VerificationKey2020 = require('./Ed25519VerificationKey2020.cjs');
var vc_crypto_common_CustomLinkedDataSignature = require('./common/CustomLinkedDataSignature.cjs');
var utils_types_bytes = require('../../utils/types/bytes.cjs');
require('bs58');
require('@juanelas/base64');
require('./Ed25519VerificationKey2018.cjs');
require('../../keypairs/keypair-ed25519.cjs');
require('@stablelib/ed25519');
require('../../types/public-keys/public-key.cjs');
require('../../types/generic/typed-enum.cjs');
require('../../utils/types/array.cjs');
require('../../utils/inheritance.cjs');
require('../../utils/types/object.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/set.cjs');
require('crypto');
require('../../utils/interfaces.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');
require('multiformats/bases/base58');
require('varint');
require('../../utils/encoding/ss-58.cjs');
require('blake2b');
require('../../utils/types/string.cjs');
require('../../types/generic/with-base.cjs');
require('../../types/generic/with-catch-null.cjs');
require('../../types/generic/with-eq.cjs');
require('../../types/generic/any-of.cjs');
require('../../types/generic/with-from.cjs');
require('../../types/generic/with-from-json-bytes.cjs');
require('../../types/generic/typed-null.cjs');
require('../../types/generic/create-placeholder.cjs');
require('../../types/generic/typed-bytes.cjs');
require('../../types/generic/typed-string.cjs');
require('../../types/generic/typed-array.cjs');
require('../../types/generic/typed-tuple.cjs');
require('../../types/generic/typed-number.cjs');
require('../../types/generic/typed-set.cjs');
require('../../types/generic/typed-map.cjs');
require('../../types/generic/typed-struct.cjs');
require('uuid');
require('js-sha256');
require('../../types/public-keys/public-key-x25519-value.cjs');
require('../../types/generic/sized.cjs');
require('../../utils/types/number.cjs');
require('../../types/public-keys/public-key-ed25519-value.cjs');
require('../../types/public-keys/public-key-secp256k1-value.cjs');
require('../../types/public-keys/public-key-sr25519-value.cjs');
require('../../types/signatures/signature-value.cjs');
require('../../types/signatures/signature.cjs');
require('../../types/signatures/signature-ed25519-value.cjs');
require('../../types/signatures/signature-secp256k1-value.cjs');
require('../../types/signatures/signature-sr25519-value.cjs');
require('../../keypairs/dock-keypair.cjs');
require('../../utils/encoding/multibase.cjs');
require('jsonld-signatures');
require('base64url');
require('jsonld');
require('../../types/did/document/verification-method-ref.cjs');
require('../../types/generic/with-qualifier.cjs');
require('../../types/generic/utils.cjs');
require('../../types/generic/typed-bytes-array.cjs');
require('../../types/did/onchain/typed-did/index.cjs');
require('../../types/did/onchain/typed-did/did-method-key/did-method-key-public-key.cjs');
require('../../utils/encoding/base-58-btc.cjs');
require('../../types/did/onchain/constants.cjs');
require('../../types/did/onchain/typed-did/signature.cjs');
require('../../types/did/onchain/typed-did/did-method-key/did-method-key-signature.cjs');
require('../../types/did/onchain/typed-did/dock-did-value.cjs');
require('../../types/generic/typed-uuid.cjs');
require('../../types/did/onchain/typed-did/cheqd-did.cjs');
require('../jws.cjs');

const SUITE_CONTEXT_URL = 'https://w3id.org/security/suites/ed25519-2020/v1';

class Ed25519Signature2020 extends vc_crypto_common_CustomLinkedDataSignature.default {
  /**
   * Creates a new Ed25519Signature2020 instance
   * @constructor
   * @param {object} config - Configuration options
   */
  constructor({
    keypair, verificationMethod, verifier, signer,
  } = {}) {
    super({
      type: vc_crypto_constants.Ed255192020SigName,
      LDKeyClass: vc_crypto_Ed25519VerificationKey2020,
      contextUrl: SUITE_CONTEXT_URL,
      alg: 'EdDSA',
      signer:
        signer
        || Ed25519Signature2020.signerFactory(keypair, verificationMethod),
      verifier,
    });
    this.requiredKeyType = vc_crypto_constants.Ed255192020VerKeyName;
  }

  /**
   * Generate object with `sign` method
   * @param keypair
   * @param verificationMethod
   * @returns {object}
   */
  static signerFactory(keypair, verificationMethod) {
    return {
      id: verificationMethod,
      async sign({ data }) {
        return utils_types_bytes.valueBytes(keypair.sign(data));
      },
    };
  }
}

module.exports = Ed25519Signature2020;
//# sourceMappingURL=Ed25519Signature2020.cjs.map
