/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import IKeyStore from '../keyStore/IKeyStore';
import CryptoFactory from './CryptoFactory';
import { SubtleCryptoElliptic } from '@microsoft/useragent-plugin-secp256k1';
import { SubtleCrypto } from 'webcrypto-core';

/**
 * Utility class to handle all CryptoFactory dependency injection for the environment node.
 * In the same way a developer can add new CryptoFactory classes that support a different device.
 */
export default class CryptoFactoryNode extends CryptoFactory{

  /**
   * Constructs a new CryptoRegistry
   * @param keyStore used to store private jeys
   * @param crypto The suite to use for dependency injection
   */
  constructor (keyStore: IKeyStore, crypto: SubtleCrypto) {
    super(keyStore, crypto);
    const operations = new SubtleCryptoElliptic(crypto);
    this.messageSigners['EdDSA'] = <any>operations;
    this.messageSigners['EDDSA'] = <any>operations;
    this.messageSigners['ed25519'] = <any>operations;
  }
}
