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

const SUITE_CONTEXT_URL = 'https://www.w3.org/2018/credentials/v1';

class Ed25519Signature2018 extends CustomLinkedDataSignature {
  /**
   * Creates a new Ed25519Signature2018 instance
   * @constructor
   * @param {object} config - Configuration options
   */
  constructor({
    keypair, verificationMethod, verifier, signer,
  } = {}) {
    super({
      type: Ed25519SigName,
      LDKeyClass: Ed25519VerificationKey2018,
      contextUrl: SUITE_CONTEXT_URL,
      alg: 'EdDSA',
      signer:
        signer
        || Ed25519Signature2018.signerFactory(keypair, verificationMethod),
      verifier,
    });
    this.requiredKeyType = Ed25519VerKeyName;
  }

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

export { Ed25519Signature2018 as default };
//# sourceMappingURL=Ed25519Signature2018.js.map
