junkurihara/jscu

View on GitHub
packages/js-crypto-ec/src/ec.ts

Summary

Maintainability
C
1 day
Test Coverage

Showing 12 of 12 total issues

Function deriveSecret has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const deriveSecret = async (publicJwk: JsonWebKey, privateJwk: JsonWebKey): Promise<Uint8Array> => {
// assertion
if(publicJwk.crv !== privateJwk.crv) throw new Error('UnmatchedCurveName');
const env = util.getCrypto();
 
 
Severity: Minor
Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

Function generateKey has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const generateKey = async (namedCurve: CurveTypes ='P-256'): Promise<JsonWebKeyPair> => {
const env = util.getCrypto();
 
let pure: boolean = false;
let keyPair: JsonWebKeyPair;
Severity: Minor
Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

Function sign has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const sign = async (
msg: Uint8Array,
privateJwk: JsonWebKey,
hash: HashTypes = 'SHA-256',
signatureFormat: SignatureFormat ='raw'
Severity: Minor
Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

Function verify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const verify = async (
msg: Uint8Array,
signature: Uint8Array,
publicJwk: JsonWebKey,
hash: HashTypes = 'SHA-256',
Severity: Minor
Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

Function deriveSecret has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const deriveSecret = async (publicJwk: JsonWebKey, privateJwk: JsonWebKey): Promise<Uint8Array> => {
// assertion
if(publicJwk.crv !== privateJwk.crv) throw new Error('UnmatchedCurveName');
const env = util.getCrypto();
 
 
Severity: Minor
Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

    Function verify has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const verify = async (
    msg: Uint8Array,
    signature: Uint8Array,
    publicJwk: JsonWebKey,
    hash: HashTypes = 'SHA-256',
    Severity: Minor
    Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

      Function sign has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const sign = async (
      msg: Uint8Array,
      privateJwk: JsonWebKey,
      hash: HashTypes = 'SHA-256',
      signatureFormat: SignatureFormat ='raw'
      Severity: Minor
      Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

        Function generateKey has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const generateKey = async (namedCurve: CurveTypes ='P-256'): Promise<JsonWebKeyPair> => {
        const env = util.getCrypto();
         
        let pure: boolean = false;
        let keyPair: JsonWebKeyPair;
        Severity: Minor
        Found in packages/js-crypto-ec/src/ec.ts - About 1 hr to fix

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          if (pure) {
          if (e instanceof Error) {
          throw new Error(`UnsupportedEnvironment: ${e.message}`);
          } else {
          throw new Error('UnsupportedEnvironment');
          Severity: Major
          Found in packages/js-crypto-ec/src/ec.ts and 3 other locations - About 35 mins to fix
          packages/js-crypto-ec/src/ec.ts on lines 34..47
          packages/js-crypto-ec/src/ec.ts on lines 134..147
          packages/js-crypto-ec/src/ec.ts on lines 179..192

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          if (pure) {
          if (e instanceof Error) {
          throw new Error(`UnsupportedEnvironment: ${e.message}`);
          } else {
          throw new Error('UnsupportedEnvironment');
          Severity: Major
          Found in packages/js-crypto-ec/src/ec.ts and 3 other locations - About 35 mins to fix
          packages/js-crypto-ec/src/ec.ts on lines 34..47
          packages/js-crypto-ec/src/ec.ts on lines 83..96
          packages/js-crypto-ec/src/ec.ts on lines 179..192

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          if (pure) {
          if (e instanceof Error) {
          throw new Error(`UnsupportedEnvironment: ${e.message}`);
          } else {
          throw new Error('UnsupportedEnvironment');
          Severity: Major
          Found in packages/js-crypto-ec/src/ec.ts and 3 other locations - About 35 mins to fix
          packages/js-crypto-ec/src/ec.ts on lines 34..47
          packages/js-crypto-ec/src/ec.ts on lines 83..96
          packages/js-crypto-ec/src/ec.ts on lines 134..147

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          if (pure) {
          if (e instanceof Error) {
          throw new Error(`UnsupportedEnvironment: ${e.message}`);
          } else {
          throw new Error('UnsupportedEnvironment');
          Severity: Major
          Found in packages/js-crypto-ec/src/ec.ts and 3 other locations - About 35 mins to fix
          packages/js-crypto-ec/src/ec.ts on lines 83..96
          packages/js-crypto-ec/src/ec.ts on lines 134..147
          packages/js-crypto-ec/src/ec.ts on lines 179..192
          Category
          Status