Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pkijs

Package Overview
Dependencies
Maintainers
2
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pkijs - npm Package Compare versions

Comparing version 2.1.46 to 2.1.47

84

build/common.js

@@ -6,2 +6,5 @@ "use strict";

});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.setEngine = setEngine;

@@ -45,10 +48,65 @@ exports.getEngine = getEngine;

function setEngine(name, crypto, subtle) {
engine = {
name: name,
crypto: crypto,
subtle: subtle
};
//region We are in Node
// noinspection JSUnresolvedVariable
if (typeof process !== "undefined") {
// noinspection ES6ModulesDependencies, JSUnresolvedVariable
if (typeof global[process.pid] === "undefined") {
// noinspection JSUnresolvedVariable
global[process.pid] = {};
} else {
// noinspection JSUnresolvedVariable
if (_typeof(global[process.pid]) !== "object") {
// noinspection JSUnresolvedVariable
throw new Error("Name global." + process.pid + " already exists and it is not an object");
}
}
// noinspection JSUnresolvedVariable
if (typeof global[process.pid].pkijs === "undefined") {
// noinspection JSUnresolvedVariable
global[process.pid].pkijs = {};
} else {
// noinspection JSUnresolvedVariable
if (_typeof(global[process.pid].pkijs) !== "object") {
// noinspection JSUnresolvedVariable
throw new Error("Name global." + process.pid + ".pkijs already exists and it is not an object");
}
}
// noinspection JSUnresolvedVariable
global[process.pid].pkijs.engine = {
name: name,
crypto: crypto,
subtle: subtle
};
}
//endregion
//region We are in browser
else {
engine = {
name: name,
crypto: crypto,
subtle: subtle
};
}
//endregion
}
//**************************************************************************************
function getEngine() {
//region We are in Node
// noinspection JSUnresolvedVariable
if (typeof process !== "undefined") {
var _engine = void 0;
try {
// noinspection JSUnresolvedVariable
_engine = global[process.pid].pkijs.engine;
} catch (ex) {
throw new Error("Please call \"setEngine\" before call to \"getEngine\"");
}
return _engine;
}
//endregion
return engine;

@@ -101,4 +159,6 @@ }

function getCrypto() {
if (engine.subtle !== null) return engine.subtle;
var _engine = getEngine();
if (_engine.subtle !== null) return _engine.subtle;
return undefined;

@@ -113,3 +173,3 @@ }

function getRandomValues(view) {
return engine.subtle.getRandomValues(view);
return getEngine().subtle.getRandomValues(view);
}

@@ -123,3 +183,3 @@ //**************************************************************************************

function getOIDByAlgorithm(algorithm) {
return engine.subtle.getOIDByAlgorithm(algorithm);
return getEngine().subtle.getOIDByAlgorithm(algorithm);
}

@@ -134,3 +194,3 @@ //**************************************************************************************

function getAlgorithmParameters(algorithmName, operation) {
return engine.subtle.getAlgorithmParameters(algorithmName, operation);
return getEngine().subtle.getAlgorithmParameters(algorithmName, operation);
}

@@ -214,3 +274,3 @@ //**************************************************************************************

if (cmsSignature.valueBlock.value[1] instanceof asn1js.Integer === false) return new ArrayBuffer(0);
//endregion
//endregion

@@ -292,3 +352,3 @@ var rValue = cmsSignature.valueBlock.value[0].convertFromDER();

function getAlgorithmByOID(oid) {
return engine.subtle.getAlgorithmByOID(oid);
return getEngine().subtle.getAlgorithmByOID(oid);
}

@@ -302,3 +362,3 @@ //**************************************************************************************

function getHashAlgorithm(signatureAlgorithm) {
return engine.subtle.getHashAlgorithm(signatureAlgorithm);
return getEngine().subtle.getHashAlgorithm(signatureAlgorithm);
}

@@ -305,0 +365,0 @@ //**************************************************************************************

2

package.json

@@ -85,4 +85,4 @@ {

"name": "pkijs",
"version": "2.1.46",
"version": "2.1.47",
"license": "MIT"
}

@@ -12,3 +12,3 @@ # PKIjs

Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto ([Web Cryptography API](http://www.w3.org/TR/WebCryptoAPI/)) and aspires to make it possible to build native web applications that utilize X.509 and the related formats on the web without plug-ins.
Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto ([**Web Cryptography API**](http://www.w3.org/TR/WebCryptoAPI/)) and aspires to make it possible to build native web applications that utilize X.509 and the related formats on the web without plug-ins.

@@ -29,7 +29,7 @@ New version of the PKIjs based on using ES6 (ES2015) and was designed with these aims in mind:

Full detailed information about all PKI.js features could be found [in separate file](FEATURES.md).
Description of PKI.js code structure could be found [in separate file](https://github.com/PeculiarVentures/PKI.js/tree/master/src/README.md).
Full detailed information about all PKI.js features could be found [**in separate file**](FEATURES.md).
Description of PKI.js code structure could be found [**in separate file**](https://github.com/PeculiarVentures/PKI.js/tree/master/src/README.md).
## Important Information for PKI.js V1 Users
PKI.js V2 (ES2015 version) is **incompatible** with PKI.js V1 code. In order to make it easier to move from PKIjs V1 code to PKIjs V2 code we made a file that provides a [mapping](MAPPING.md) between old and new class names.
PKI.js V2 (ES2015 version) is **incompatible** with PKI.js V1 code. In order to make it easier to move from PKIjs V1 code to PKIjs V2 code we made a file that provides a [**mapping**](MAPPING.md) between old and new class names.

@@ -72,6 +72,6 @@ ## Examples

certificate.extensions = new Array(); // Extensions are not a part of certificate by default, it's an optional array
certificate.extensions = []; // Extensions are not a part of certificate by default, it's an optional array
//region "BasicConstraints" extension
var basicConstr = new BasicConstraints({
const basicConstr = new BasicConstraints({
cA: true,

@@ -90,9 +90,9 @@ pathLenConstraint: 3

//region "KeyUsage" extension
var bitArray = new ArrayBuffer(1);
var bitView = new Uint8Array(bitArray);
const bitArray = new ArrayBuffer(1);
const bitView = new Uint8Array(bitArray);
bitView[0] = bitView[0] | 0x02; // Key usage "cRLSign" flag
bitView[0] = bitView[0] | 0x04; // Key usage "keyCertSign" flag
bitView[0] |= 0x02; // Key usage "cRLSign" flag
bitView[0] |= 0x04; // Key usage "keyCertSign" flag
var keyUsage = new asn1js.BitString({ valueHex: bitArray });
const keyUsage = new asn1js.BitString({ valueHex: bitArray });

@@ -129,3 +129,3 @@ certificate.extensions.push(new Extension({

return cms_signed_simpl.sign(privateKey, 0, hashAlgorithm);
return cmsSigned.sign(privateKey, 0, hashAlgorithm);
//endregion

@@ -160,3 +160,3 @@

- Make a correct main ES6 file (initial application). It could be not a separate ES6 file, but a script on your page, but anyway it must has exports inside `windows` namespace in order to communicate with Web page:
```javascript 1.8
```javascript
window.handleFileBrowseParseEncrypted = handleFileBrowseParseEncrypted;

@@ -203,3 +203,3 @@ window.handleFileBrowseCreateEncrypted = handleFileBrowseCreateEncrypted;

```
```command
npm install

@@ -209,3 +209,3 @@ npm run build:examples

Live examples can be found at [pkijs.org](https://pkijs.org).
Live examples can be found at [**pkijs.org**](https://pkijs.org).

@@ -215,12 +215,14 @@ ## Tests using Node environment

**WARNING:**
!!! in order to test PKIjs in Node environment you would need to install additional package `node-webcrypto-ossl` !!!
**!!!** in order to test PKIjs in Node environment you would need to install additional package `node-webcrypto-ossl` **!!!**
The `node-webcrypto-ossl` is not referenced in PKIjs dependencies anymore because we were noticed users have a problems with the package installation, especially on Windows platform.
The `node-webcrypto-ossl` is NOT a mandatory for testing PKIjs - you could visit test/browser subdir and run all the same tests in your favorite browser.
The `node-webcrypto-ossl` is NOT a mandatory for testing PKIjs - you could visit `test/browser` subdir and run all the same tests in your favorite browser.
Also you could check [CircleCI](https://circleci.com/gh/PeculiarVentures/PKI.js) - for each build the service runs all tests and results could be easily observed.
Also you could check [**CircleCI**](https://circleci.com/gh/PeculiarVentures/PKI.js) - for each build the service runs all tests and results could be easily observed.
If you do need to run PKIjs tests locally using Node please use
```command
npm run build:examples
npm run test:node

@@ -231,5 +233,5 @@ ```

* Safari, Edge, and IE do not have complete, or correct implementations of Web Crypto. To work around these limitations you will probably need [`webcrypto-liner`](https://github.com/PeculiarVentures/webcrypto-liner/).
* You can check the capabilities of your browser's Web Crypto implementation [here](https://peculiarventures.github.io/pv-webcrypto-tests/).
* Web Crypto support in browsers is always improving. Please check [this page](http://caniuse.com/#feat=cryptography) for information about Web Cryptography API browser support.
* Safari, Edge, and IE do not have complete, or correct implementations of Web Crypto. To work around these limitations you will probably need [**webcrypto-liner**](https://github.com/PeculiarVentures/webcrypto-liner/).
* You can check the capabilities of your browser's Web Crypto implementation [**here**](https://peculiarventures.github.io/pv-webcrypto-tests/).
* Web Crypto support in browsers is always improving. Please check [**this page**](http://caniuse.com/#feat=cryptography) for information about Web Cryptography API browser support.

@@ -244,12 +246,12 @@ ## Suitability

* [ASN1js project](https://github.com/PeculiarVentures/ASN1.js) - in fact [PKIjs][] will not work without [ASN1js][], it's neccessary part of the [PKIjs][] project;
* [C++ ASN1:2008 BER coder/decoder](https://github.com/YuryStrozhevsky/C-plus-plus-ASN.1-2008-coder-decoder) - the "father" of [ASN1js][] project;
* [Freely available ASN.1:2008 test suite](https://github.com/YuryStrozhevsky/ASN1-2008-free-test-suite) - the suite which can help you to validate (and better understand) any ASN.1 coder/decoder;
* [**ASN1js project**](https://github.com/PeculiarVentures/ASN1.js) - in fact **[PKIjs][]** will not work without **[ASN1js][]**, it's neccessary part of the **[PKIjs][]** project;
* [**C++ ASN1:2008 BER coder/decoder**](https://github.com/YuryStrozhevsky/C-plus-plus-ASN.1-2008-coder-decoder) - the "father" of **[ASN1js][]** project;
* [**Freely available ASN.1:2008 test suite**](https://github.com/YuryStrozhevsky/ASN1-2008-free-test-suite) - the suite which can help you to validate (and better understand) any ASN.1 coder/decoder;
## License
Copyright (c) 2016-2018, [Peculiar Ventures](http://peculiarventures.com/)
All rights reserved.
*Copyright (c) 2016-2018, [**Peculiar Ventures**](http://peculiarventures.com/)*
*All rights reserved.*
Author 2016-2018 [Yury Strozhevsky](http://www.strozhevsky.com/).
*Author 2014-2018 [**Yury Strozhevsky**](http://www.strozhevsky.com/).*

@@ -270,3 +272,3 @@ Redistribution and use in source and binary forms, with or without modification,

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

@@ -280,3 +282,3 @@ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
OF SUCH DAMAGE.*

@@ -296,3 +298,3 @@

BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.
See <http://www.wassenaar.org/> for more information.
See **<http://www.wassenaar.org/>** for more information.

@@ -299,0 +301,0 @@ The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms.

@@ -15,7 +15,56 @@ import * as asn1js from "asn1js";

{
engine = {
name,
crypto,
subtle
};
//region We are in Node
// noinspection JSUnresolvedVariable
if(typeof process !== "undefined")
{
// noinspection ES6ModulesDependencies, JSUnresolvedVariable
if(typeof global[process.pid] === "undefined")
{
// noinspection JSUnresolvedVariable
global[process.pid] = {};
}
else
{
// noinspection JSUnresolvedVariable
if(typeof global[process.pid] !== "object")
{
// noinspection JSUnresolvedVariable
throw new Error(`Name global.${process.pid} already exists and it is not an object`);
}
}
// noinspection JSUnresolvedVariable
if(typeof global[process.pid].pkijs === "undefined")
{
// noinspection JSUnresolvedVariable
global[process.pid].pkijs = {};
}
else
{
// noinspection JSUnresolvedVariable
if(typeof global[process.pid].pkijs !== "object")
{
// noinspection JSUnresolvedVariable
throw new Error(`Name global.${process.pid}.pkijs already exists and it is not an object`);
}
}
// noinspection JSUnresolvedVariable
global[process.pid].pkijs.engine = {
name: name,
crypto: crypto,
subtle: subtle
};
}
//endregion
//region We are in browser
else
{
engine = {
name: name,
crypto: crypto,
subtle: subtle
};
}
//endregion
}

@@ -25,2 +74,22 @@ //**************************************************************************************

{
//region We are in Node
// noinspection JSUnresolvedVariable
if(typeof process !== "undefined")
{
let _engine;
try
{
// noinspection JSUnresolvedVariable
_engine = global[process.pid].pkijs.engine;
}
catch(ex)
{
throw new Error("Please call \"setEngine\" before call to \"getEngine\"");
}
return _engine;
}
//endregion
return engine;

@@ -36,3 +105,3 @@ }

let engineName = "webcrypto";
/**

@@ -45,3 +114,3 @@ * Standard crypto object

let subtleObject = null;
// Apple Safari support

@@ -61,6 +130,6 @@ if("webkitSubtle" in self.crypto)

}
if("subtle" in self.crypto)
subtleObject = self.crypto.subtle;
engine = {

@@ -85,5 +154,7 @@ name: engineName,

{
if(engine.subtle !== null)
return engine.subtle;
const _engine = getEngine();
if(_engine.subtle !== null)
return _engine.subtle;
return undefined;

@@ -99,3 +170,3 @@ }

{
return engine.subtle.getRandomValues(view);
return getEngine().subtle.getRandomValues(view);
}

@@ -110,3 +181,3 @@ //**************************************************************************************

{
return engine.subtle.getOIDByAlgorithm(algorithm);
return getEngine().subtle.getOIDByAlgorithm(algorithm);
}

@@ -122,3 +193,3 @@ //**************************************************************************************

{
return engine.subtle.getAlgorithmParameters(algorithmName, operation);
return getEngine().subtle.getAlgorithmParameters(algorithmName, operation);
}

@@ -219,3 +290,3 @@ //**************************************************************************************

return new ArrayBuffer(0);
//endregion
//endregion

@@ -302,3 +373,3 @@ const rValue = cmsSignature.valueBlock.value[0].convertFromDER();

{
return engine.subtle.getAlgorithmByOID(oid);
return getEngine().subtle.getAlgorithmByOID(oid);
}

@@ -313,3 +384,3 @@ //**************************************************************************************

{
return engine.subtle.getHashAlgorithm(signatureAlgorithm);
return getEngine().subtle.getHashAlgorithm(signatureAlgorithm);
}

@@ -316,0 +387,0 @@ //**************************************************************************************

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc