How to use the jsrsasign.KEYUTIL.getJWKFromKey function in jsrsasign

To help you get started, we’ve selected a few jsrsasign examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / EditEntry.js View on Github external
getKeyID(value){
        var encodedKey = null;
        try{
            encodedKey=JSON.parse(value);
        }catch(e){
            // the key is not JSON formatted
            encodedKey=value;
        }
        keyID = "";
        try{
            var pubKey = KEYUTIL.getKey(encodedKey);
            // this part won't fail
            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
        }catch(e){
            // the key cannot be retrieved.
            console.log(e);
        }
        return keyID;
    }
github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / KeyEntry.js View on Github external
updateContent(event){
        event.preventDefault();
        this.setState({animationClasses:"keyEntry"});
        console.log(this.state.animationClasses)
        try{
            var jwtPub = JSON.parse(this.state.jwt);
        }catch(e){
            jwtPub = this.state.jwt;
        }
        try{
            var pubKey = KEYUTIL.getKey(jwtPub);
            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            this.setState({jwt: JSON.stringify(jwkPub)})
            // Dynamically generating a key id is counterintuitive when you 
            // can just add a new key that will auto-generate an ID.  
            // In the unlikely event that users want to be able to directly
            // edit an existing key (aka, acutally editing the text in
            // the PEM string, or the JSON) this could be useful, but I doubt that anybody
            // will be changing individual characters in an encoded string.  
            
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
            if(keyID !=this.state.kid){
                this.props.updateIdCB(this.state.kid,keyID, jwkPub);
                this.setState({kid: keyID});
            }
            this.setState({data: "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(jwkPub))});
github HL7-DaVinci / CRD / request-generator / src / containers / RequestBuilder.js View on Github external
async createJwt(){
      var pubKey = this.state.keypair.pubKeyObj;
    
      const jwkPrv2 = KEYUTIL.getJWKFromKey(this.state.keypair.prvKeyObj);
      const jwkPub2 = KEYUTIL.getJWKFromKey(this.state.keypair.pubKeyObj);
      console.log(pubKey);
      const currentTime = KJUR.jws.IntDate.get('now');
      const endTime = KJUR.jws.IntDate.get('now + 1day');
      const kid = KJUR.jws.JWS.getJWKthumbprint(jwkPub2)
      // const pubPem = {"pem":KEYUTIL.getPEM(pubKey),"id":kid};
      const pubPem = {"pem":jwkPub2,"id":kid};

      // Check if the public key is already in the db
      const checkForPublic = await fetch("http://localhost:3001/public_keys?id="+kid,{
        "headers":{
          "Content-Type":"application/json"
        },
        "method":"GET"
      }).then(response => {return response.json()});
      if(!checkForPublic.length){
github HL7-DaVinci / CRD / request-generator / src / containers / RequestBuilder.js View on Github external
async createJwt(){
      var pubKey = this.state.keypair.pubKeyObj;
    
      const jwkPrv2 = KEYUTIL.getJWKFromKey(this.state.keypair.prvKeyObj);
      const jwkPub2 = KEYUTIL.getJWKFromKey(this.state.keypair.pubKeyObj);
      console.log(pubKey);
      const currentTime = KJUR.jws.IntDate.get('now');
      const endTime = KJUR.jws.IntDate.get('now + 1day');
      const kid = KJUR.jws.JWS.getJWKthumbprint(jwkPub2)
      // const pubPem = {"pem":KEYUTIL.getPEM(pubKey),"id":kid};
      const pubPem = {"pem":jwkPub2,"id":kid};

      // Check if the public key is already in the db
      const checkForPublic = await fetch("http://localhost:3001/public_keys?id="+kid,{
        "headers":{
          "Content-Type":"application/json"
        },
        "method":"GET"
      }).then(response => {return response.json()});
      if(!checkForPublic.length){
        // POST key to db if it's not already there
github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / EditEntry.js View on Github external
updateContent(event){
        try{
            var jwtPub = JSON.parse(this.state.jwt);
        }catch(e){
            jwtPub = this.state.jwt;
        }
        try{
            var pubKey = KEYUTIL.getKey(jwtPub);

            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            this.setState({jwt: JSON.stringify(jwkPub)})
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
            // this.props.updateIdCB(this.state.kid,keyID, jwkPub);
            this.setState({kid: keyID});

            
        }catch(e){
        }

        
        
        event.preventDefault();
        if(!this.state.editMode){
            this.setState({editMode:true});
        }else{
            this.setState({editMode:false});

jsrsasign

opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK)

MIT
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis